Skip to content

Commit

Permalink
Merge pull request #5662 from nicofrand/fixReconnect
Browse files Browse the repository at this point in the history
Request the native app to reload the direct editing view on 403 errors
  • Loading branch information
max-nextcloud authored Jul 2, 2024
2 parents d095146 + 602ed15 commit 5abc415
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
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

0 comments on commit 5abc415

Please sign in to comment.