diff --git a/native/calendar/entry.react.js b/native/calendar/entry.react.js --- a/native/calendar/entry.react.js +++ b/native/calendar/entry.react.js @@ -221,7 +221,7 @@ textInput: ?React.ElementRef; creating: boolean = false; needsUpdateAfterCreation: boolean = false; - needsDeleteAfterCreation: boolean = false; + needsDeleteAfterSave: boolean = false; nextSaveAttemptIndex: number = 0; mounted: boolean = false; deleted: boolean = false; @@ -651,12 +651,13 @@ this.guardedSetState({ loadingStatus: 'inactive' }); } this.creating = false; + this.currentlySaving = null; if (this.needsUpdateAfterCreation) { this.needsUpdateAfterCreation = false; this.dispatchSave(response.entryID, this.state.text); } - if (this.needsDeleteAfterCreation) { - this.needsDeleteAfterCreation = false; + if (this.needsDeleteAfterSave) { + this.needsDeleteAfterSave = false; this.dispatchDelete(response.entryID, this.state.text); } return response; @@ -686,6 +687,11 @@ if (curSaveAttempt + 1 === this.nextSaveAttemptIndex) { this.guardedSetState({ loadingStatus: 'inactive' }); } + this.currentlySaving = null; + if (this.needsDeleteAfterSave) { + this.needsDeleteAfterSave = false; + this.dispatchDelete(response.entryID, this.state.text); + } return { ...response, threadID: this.props.entryInfo.threadID }; } catch (e) { if (curSaveAttempt + 1 === this.nextSaveAttemptIndex) { @@ -731,8 +737,8 @@ dispatchDelete(serverID: ?string, prevText: string) { if (this.deleted) { return; - } else if (this.creating) { - this.needsDeleteAfterCreation = true; + } else if (this.creating || this.currentlySaving) { + this.needsDeleteAfterSave = true; return; } this.deleted = true;