Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 104ae6f

Browse files
author
Max Stoiber
committed
Fix flow
1 parent 52bd78d commit 104ae6f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/views/thread/components/threadDetail.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,17 @@ class ThreadDetailPure extends React.Component<Props, State> {
309309
uploadFiles = files => {
310310
const uploading = `![Uploading ${files[0].name}...]()`;
311311
let caretPos = this.bodyEditor.selectionStart;
312+
const { body } = this.state;
313+
if (!body) return;
312314

313315
this.setState(
314-
({ body }) => ({
316+
{
315317
isSavingEdit: true,
316318
body:
317319
body.substring(0, caretPos) +
318320
uploading +
319-
body.substring(this.bodyEditor.selectionEnd, this.state.body.length),
320-
}),
321+
body.substring(this.bodyEditor.selectionEnd, body.length),
322+
},
321323
() => {
322324
caretPos = caretPos + uploading.length;
323325
this.bodyEditor.selectionStart = caretPos;
@@ -335,6 +337,7 @@ class ThreadDetailPure extends React.Component<Props, State> {
335337
this.setState({
336338
isSavingEdit: false,
337339
});
340+
if (!this.state.body) return;
338341
this.changeBody({
339342
target: {
340343
value: this.state.body.replace(
@@ -349,6 +352,7 @@ class ThreadDetailPure extends React.Component<Props, State> {
349352
this.setState({
350353
isSavingEdit: false,
351354
});
355+
if (!this.state.body) return;
352356
this.changeBody({
353357
target: {
354358
value: this.state.body.replace(uploading, ''),

0 commit comments

Comments
 (0)