Skip to content

Commit 4fb14ca

Browse files
nicofrandmejo-
authored andcommitted
Request the native app to reload the direct editing view on 403 errors
Signed-off-by: nicofrand <[email protected]>
1 parent 07528d6 commit 4fb14ca

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/components/Editor.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,12 @@ export default {
593593
this.hasConnectionIssue = true
594594
}
595595
596+
if (type === ERROR_TYPE.PUSH_FORBIDDEN) {
597+
this.hasConnectionIssue = true
598+
this.emit('push:forbidden')
599+
return
600+
}
601+
596602
this.emit('ready')
597603
},
598604

src/services/SyncService.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ const ERROR_TYPE = {
6363
CONNECTION_FAILED: 3,
6464

6565
SOURCE_NOT_FOUND: 4,
66+
67+
PUSH_FORBIDDEN: 5,
6668
}
6769

6870
class SyncService {
@@ -203,6 +205,7 @@ class SyncService {
203205
if (!data.document) {
204206
// either the session is invalid or the document is read only.
205207
logger.error('failed to write to document - not allowed')
208+
this.emit('error', { type: ERROR_TYPE.PUSH_FORBIDDEN, data: {} })
206209
}
207210
// Only emit conflict event if we have synced until the latest version
208211
if (response.data.document?.currentVersion === this.version) {

src/views/DirectEditing.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ export default {
114114
},
115115
mounted() {
116116
document.querySelector('meta[name="viewport"]').setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0')
117+
118+
this.$refs.editor.$on('push:forbidden', () => {
119+
logger.warn('push was forbidden due to invalidated session')
120+
this.reload()
121+
})
117122
},
118123
methods: {
119124
async close() {
@@ -129,6 +134,9 @@ export default {
129134
loaded() {
130135
callMobileMessage('loaded')
131136
},
137+
reload() {
138+
callMobileMessage('reload')
139+
},
132140
},
133141
}
134142
</script>

0 commit comments

Comments
 (0)