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

Commit

Permalink
Fix flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Stoiber committed Mar 9, 2019
1 parent 52bd78d commit 104ae6f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/views/thread/components/threadDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,17 @@ class ThreadDetailPure extends React.Component<Props, State> {
uploadFiles = files => {
const uploading = `![Uploading ${files[0].name}...]()`;
let caretPos = this.bodyEditor.selectionStart;
const { body } = this.state;
if (!body) return;

this.setState(
({ body }) => ({
{
isSavingEdit: true,
body:
body.substring(0, caretPos) +
uploading +
body.substring(this.bodyEditor.selectionEnd, this.state.body.length),
}),
body.substring(this.bodyEditor.selectionEnd, body.length),
},
() => {
caretPos = caretPos + uploading.length;
this.bodyEditor.selectionStart = caretPos;
Expand All @@ -335,6 +337,7 @@ class ThreadDetailPure extends React.Component<Props, State> {
this.setState({
isSavingEdit: false,
});
if (!this.state.body) return;
this.changeBody({
target: {
value: this.state.body.replace(
Expand All @@ -349,6 +352,7 @@ class ThreadDetailPure extends React.Component<Props, State> {
this.setState({
isSavingEdit: false,
});
if (!this.state.body) return;
this.changeBody({
target: {
value: this.state.body.replace(uploading, ''),
Expand Down

0 comments on commit 104ae6f

Please sign in to comment.