Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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')
},

Expand Down
3 changes: 3 additions & 0 deletions src/services/SyncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ const ERROR_TYPE = {
CONNECTION_FAILED: 3,

SOURCE_NOT_FOUND: 4,

PUSH_FORBIDDEN: 5,
}

class SyncService {
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions src/views/DirectEditing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -129,6 +134,9 @@ export default {
loaded() {
callMobileMessage('loaded')
},
reload() {
callMobileMessage('reload')
},
},
}
</script>
Expand Down