diff --git a/src/components/Editor.vue b/src/components/Editor.vue index b716b6af69c..8fadb7cb891 100644 --- a/src/components/Editor.vue +++ b/src/components/Editor.vue @@ -593,6 +593,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 e05336d8a01..9db0a1050fa 100644 --- a/src/services/SyncService.js +++ b/src/services/SyncService.js @@ -63,6 +63,8 @@ const ERROR_TYPE = { CONNECTION_FAILED: 3, SOURCE_NOT_FOUND: 4, + + PUSH_FORBIDDEN: 5, } class SyncService { @@ -203,6 +205,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 4afcfc3f46d..8fc5a2a8f53 100644 --- a/src/views/DirectEditing.vue +++ b/src/views/DirectEditing.vue @@ -114,6 +114,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() { @@ -129,6 +134,9 @@ export default { loaded() { callMobileMessage('loaded') }, + reload() { + callMobileMessage('reload') + }, }, }