diff options
author | Julius Härtl <jus@bitgrid.net> | 2020-11-25 12:01:19 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2020-12-02 17:26:50 +0300 |
commit | 44bdb13119e547616634d0a0a113209c8ff5c2ee (patch) | |
tree | e594c576a45653582f48e3133a37e95c9c09637d /src | |
parent | de706b439874975c9849fc7c7ecf4b7cb66ce4e1 (diff) |
Properly stop document fetching in error states and always require to reconnect manually
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/EditorWrapper.vue | 16 | ||||
-rw-r--r-- | src/services/PollingBackend.js | 8 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/components/EditorWrapper.vue b/src/components/EditorWrapper.vue index 2c8573828..a2d6b27de 100644 --- a/src/components/EditorWrapper.vue +++ b/src/components/EditorWrapper.vue @@ -26,14 +26,14 @@ <p v-if="idle" class="msg icon-info"> {{ t('text', 'Document idle for {timeout} minutes, click to continue editing', { timeout: IDLE_TIMEOUT }) }} <a class="button primary" @click="reconnect">{{ t('text', 'Reconnect') }}</a> </p> - <p v-if="hasSyncCollission" class="msg icon-error"> + <p v-else-if="hasSyncCollission" class="msg icon-error"> {{ t('text', 'The document has been changed outside of the editor. The changes cannot be applied.') }} </p> - <p v-if="hasConnectionIssue" class="msg icon-info"> + <p v-else-if="hasConnectionIssue" class="msg icon-info"> {{ t('text', 'File could not be loaded. Please check your internet connection.') }} <a class="button primary" @click="reconnect">{{ t('text', 'Reconnect') }}</a> </p> </div> - <div v-if="currentSession && active" id="editor-wrapper" :class="{'has-conflicts': hasSyncCollission, 'icon-loading': !initialLoading || hasConnectionIssue, 'richEditor': isRichEditor}"> + <div v-if="currentSession && active" id="editor-wrapper" :class="{'has-conflicts': hasSyncCollission, 'icon-loading': !initialLoading && !hasConnectionIssue, 'richEditor': isRichEditor}"> <div id="editor"> <MenuBar v-if="!syncError && !readOnly" ref="menubar" @@ -55,7 +55,7 @@ <div> <MenuBubble v-if="!readOnly && isRichEditor" :editor="tiptap" - :filePath="relativePath" /> + :file-path="relativePath" /> <EditorContent v-show="initialLoading" class="editor__content" :editor="tiptap" /> @@ -381,10 +381,9 @@ export default { } } if (error === ERROR_TYPE.SOURCE_NOT_FOUND) { - this.initialLoading = false - this.$emit('close') - this.$emit('error') + this.hasConnectionIssue = true } + this.$emit('ready') }) .on('stateChange', (state) => { if (state.initialLoading && !this.initialLoading) { @@ -433,7 +432,8 @@ export default { }, reconnect() { - this.initialLoading = true + this.initialLoading = false + this.hasConnectionIssue = false if (this.syncService) { this.syncService.close().then(() => { this.syncService = null diff --git a/src/services/PollingBackend.js b/src/services/PollingBackend.js index a65300248..42349451d 100644 --- a/src/services/PollingBackend.js +++ b/src/services/PollingBackend.js @@ -159,7 +159,7 @@ class PollingBackend { if (!e.response || e.code === 'ECONNABORTED') { if (this.fetchRetryCounter++ >= MAX_RETRY_FETCH_COUNT) { console.error('[PollingBackend:fetchSteps] Network error when fetching steps, emitting CONNECTION_FAILED') - this._authority.emit('error', ERROR_TYPE.CONNECTION_FAILED, {}) + this._authority.emit('error', ERROR_TYPE.CONNECTION_FAILED, { retry: false }) } else { console.error(`[PollingBackend:fetchSteps] Network error when fetching steps, retry ${this.fetchRetryCounter}`) @@ -172,14 +172,16 @@ class PollingBackend { }) } else if (e.response.status === 403) { this._authority.emit('error', ERROR_TYPE.SOURCE_NOT_FOUND, {}) + this.disconnect() } else if (e.response.status === 404) { this._authority.emit('error', ERROR_TYPE.SOURCE_NOT_FOUND, {}) + this.disconnect() } else if (e.response.status === 503) { this.increaseRefetchTimer() - this._authority.emit('error', ERROR_TYPE.CONNECTION_FAILED, { retry: true }) + this._authority.emit('error', ERROR_TYPE.CONNECTION_FAILED, { retry: false }) console.error('Failed to fetch steps due to unavailable service', e) } else { - this.increaseRefetchTimer() + this.disconnect() this._authority.emit('error', ERROR_TYPE.CONNECTION_FAILED, { retry: false }) console.error('Failed to fetch steps due to other reason', e) } |