diff options
author | Julius Härtl <jus@bitgrid.net> | 2020-01-09 18:41:01 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2020-01-09 23:26:41 +0300 |
commit | 195f396b7eb3e90b9206deca9207454436117eb2 (patch) | |
tree | 09ed8c16d43bdb2aa70dcff613e9d962b2235283 /src | |
parent | 64b13e96b7d90bd7b0ff1f4b575803c3437bbdb0 (diff) |
Save file before closing (fix #527)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/EditorWrapper.vue | 25 | ||||
-rw-r--r-- | src/views/DirectEditing.vue | 14 |
2 files changed, 25 insertions, 14 deletions
diff --git a/src/components/EditorWrapper.vue b/src/components/EditorWrapper.vue index 5799395c0..f4320d6d3 100644 --- a/src/components/EditorWrapper.vue +++ b/src/components/EditorWrapper.vue @@ -232,18 +232,23 @@ export default { document.addEventListener('keydown', this._keyUpHandler, true) }, beforeDestroy() { - document.removeEventListener('keydown', this._keyUpHandler, true) - clearInterval(this.saveStatusPolling) - if (this.currentSession && this.syncService) { - this.syncService.close().then(() => { - this.currentSession = null - this.syncService = null - }).catch((e) => { - // Ignore issues closing the session since those might happen due to network issues - }) - } + this.close() }, methods: { + async close() { + document.removeEventListener('keydown', this._keyUpHandler, true) + clearInterval(this.saveStatusPolling) + if (this.currentSession && this.syncService) { + try { + await this.syncService.close() + this.currentSession = null + this.syncService = null + } catch (e) { + // Ignore issues closing the session since those might happen due to network issues + } + } + return true + }, updateLastSavedStatus() { if (this.document) { this.lastSavedString = window.moment(this.document.lastSavedVersionTime * 1000).fromNow() diff --git a/src/views/DirectEditing.vue b/src/views/DirectEditing.vue index 1f479786f..f4010b528 100644 --- a/src/views/DirectEditing.vue +++ b/src/views/DirectEditing.vue @@ -21,8 +21,9 @@ --> <template> - <div id="direct-editor"> - <EditorWrapper :initial-session="initialSession" + <div id="direct-editor" :class="{'icon-loading': saving}"> + <EditorWrapper ref="editor" + :initial-session="initialSession" :active="true" mime="text/markdown" :is-direct-editing="true" @@ -92,6 +93,7 @@ export default { initial: OCP.InitialState.loadState('text', 'file'), messages: log.messages, log: log, + saving: false, } }, computed: { @@ -103,8 +105,12 @@ export default { callMobileMessage('loading') }, methods: { - close() { - callMobileMessage('close') + async close() { + this.saving = true + setTimeout(async() => { + await this.$refs.editor.close() + callMobileMessage('close') + }, 0) }, share() { callMobileMessage('share') |