Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request the native app to reload the direct editing view on 403 errors #5662

Merged
merged 1 commit into from
Jul 2, 2024
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 @@ -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')
},

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

SOURCE_NOT_FOUND: 4,

PUSH_FORBIDDEN: 5,
}

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