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
4 changes: 2 additions & 2 deletions js/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/files-modal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/files-modal.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions js/text-editors.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-editors.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-files.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-text.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-text.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-viewer.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,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 @@ -62,6 +62,8 @@ const ERROR_TYPE = {
CONNECTION_FAILED: 3,

SOURCE_NOT_FOUND: 4,

PUSH_FORBIDDEN: 5,
}

class SyncService {
Expand Down Expand Up @@ -188,6 +190,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