mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 04:41:43 +03:00
Merge pull request #1048 from esteemapp/bugfix/comment-draft
Fixed comment draft issue
This commit is contained in:
commit
abe582fd9f
@ -269,7 +269,7 @@ class EditorContainer extends Component {
|
||||
};
|
||||
|
||||
_saveCurrentDraft = async fields => {
|
||||
const { draftId, isReply, isEdit } = this.state;
|
||||
const { draftId, isReply, isEdit, isPostSending } = this.state;
|
||||
|
||||
if (!draftId && !isEdit) {
|
||||
const { currentAccount } = this.props;
|
||||
@ -279,11 +279,12 @@ class EditorContainer extends Component {
|
||||
...fields,
|
||||
tags: fields.tags && fields.tags.length > 0 ? fields.tags.toString() : '',
|
||||
};
|
||||
|
||||
if (isReply && draftField.body) {
|
||||
await AsyncStorage.setItem('temp-reply', draftField.body);
|
||||
} else {
|
||||
setDraftPost(draftField, username);
|
||||
if (!isPostSending) {
|
||||
if (isReply && draftField.body) {
|
||||
await AsyncStorage.setItem('temp-reply', draftField.body);
|
||||
} else {
|
||||
setDraftPost(draftField, username);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -451,6 +452,7 @@ class EditorContainer extends Component {
|
||||
jsonMeta,
|
||||
)
|
||||
.then(() => {
|
||||
AsyncStorage.setItem('temp-reply', '');
|
||||
this._handleSubmitSuccess();
|
||||
})
|
||||
.catch(error => {
|
||||
@ -468,7 +470,10 @@ class EditorContainer extends Component {
|
||||
}),
|
||||
error.message || error.toString(),
|
||||
);
|
||||
this.setState({ isPostSending: false });
|
||||
this.stateTimer = setTimeout(() => {
|
||||
this.setState({ isPostSending: false });
|
||||
clearTimeout(this.stateTimer);
|
||||
}, 500);
|
||||
};
|
||||
|
||||
_handleSubmitSuccess = () => {
|
||||
@ -479,7 +484,10 @@ class EditorContainer extends Component {
|
||||
navigation.state.params.fetchPost();
|
||||
}
|
||||
|
||||
this.setState({ isPostSending: false });
|
||||
this.stateTimer = setTimeout(() => {
|
||||
this.setState({ isPostSending: false });
|
||||
clearTimeout(this.stateTimer);
|
||||
}, 500);
|
||||
};
|
||||
|
||||
_handleOnBackPress = () => {
|
||||
|
@ -93,9 +93,8 @@ class EditorScreen extends Component {
|
||||
saveDraftToDB(fields);
|
||||
};
|
||||
|
||||
_saveCurrentDraft = () => {
|
||||
_saveCurrentDraft = fields => {
|
||||
const { saveCurrentDraft } = this.props;
|
||||
const { fields } = this.state;
|
||||
|
||||
if (this.changeTimer) {
|
||||
clearTimeout(this.changeTimer);
|
||||
@ -149,12 +148,12 @@ class EditorScreen extends Component {
|
||||
get(fields, 'tags') !== get(_fields, 'tags')
|
||||
) {
|
||||
handleFormChanged();
|
||||
this._saveCurrentDraft(fields);
|
||||
}
|
||||
|
||||
this.setState({ fields });
|
||||
|
||||
this._handleIsFormValid();
|
||||
this._saveCurrentDraft();
|
||||
};
|
||||
|
||||
_handleOnTagAdded = async tags => {
|
||||
|
Loading…
Reference in New Issue
Block a user