diff --git a/src/components/Editor.vue b/src/components/Editor.vue index 0217e4babc1..c12dca0b194 100644 --- a/src/components/Editor.vue +++ b/src/components/Editor.vue @@ -597,6 +597,12 @@ export default { this.hasConnectionIssue = true } + if (type === ERROR_TYPE.PUSH_FORBIDDEN) { + this.hasConnectionIssue = true + this.emit('push:forbidden') + return + } + this.emit('ready') }, diff --git a/src/services/SyncService.js b/src/services/SyncService.js index 349dd75f0d0..527686e41fd 100644 --- a/src/services/SyncService.js +++ b/src/services/SyncService.js @@ -47,6 +47,8 @@ const ERROR_TYPE = { CONNECTION_FAILED: 3, SOURCE_NOT_FOUND: 4, + + PUSH_FORBIDDEN: 5, } class SyncService { @@ -170,6 +172,7 @@ class SyncService { if (!data.document) { // either the session is invalid or the document is read only. logger.error('failed to write to document - not allowed') + this.emit('error', { type: ERROR_TYPE.PUSH_FORBIDDEN, data: {} }) } // Only emit conflict event if we have synced until the latest version if (response.data.document?.currentVersion === this.version) { diff --git a/src/views/DirectEditing.vue b/src/views/DirectEditing.vue index d6b1b1581f3..f93c0938841 100644 --- a/src/views/DirectEditing.vue +++ b/src/views/DirectEditing.vue @@ -97,6 +97,11 @@ export default { }, mounted() { document.querySelector('meta[name="viewport"]').setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0') + + this.$refs.editor.$on('push:forbidden', () => { + logger.warn('push was forbidden due to invalidated session') + this.reload() + }) }, methods: { async close() { @@ -112,6 +117,9 @@ export default { loaded() { callMobileMessage('loaded') }, + reload() { + callMobileMessage('reload') + }, }, }