Skip to content

Commit 9cdc19f

Browse files
nicofrandmax-nextcloud
authored andcommitted
Request the native app to reload the direct editing view on 403 errors
1 parent fe746fa commit 9cdc19f

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
@@ -597,6 +597,12 @@ export default {
597597
this.hasConnectionIssue = true
598598
}
599599
600+
if (type === ERROR_TYPE.PUSH_FORBIDDEN) {
601+
this.hasConnectionIssue = true
602+
this.emit('push:forbidden')
603+
return
604+
}
605+
600606
this.emit('ready')
601607
},
602608

src/services/SyncService.js

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

4949
SOURCE_NOT_FOUND: 4,
50+
51+
PUSH_FORBIDDEN: 5,
5052
}
5153

5254
class SyncService {
@@ -170,6 +172,7 @@ class SyncService {
170172
if (!data.document) {
171173
// either the session is invalid or the document is read only.
172174
logger.error('failed to write to document - not allowed')
175+
this.emit('error', { type: ERROR_TYPE.PUSH_FORBIDDEN, data: {} })
173176
}
174177
// Only emit conflict event if we have synced until the latest version
175178
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
@@ -97,6 +97,11 @@ export default {
9797
},
9898
mounted() {
9999
document.querySelector('meta[name="viewport"]').setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0')
100+
101+
this.$refs.editor.$on('push:forbidden', () => {
102+
logger.warn('push was forbidden due to invalidated session')
103+
this.reload()
104+
})
100105
},
101106
methods: {
102107
async close() {
@@ -112,6 +117,9 @@ export default {
112117
loaded() {
113118
callMobileMessage('loaded')
114119
},
120+
reload() {
121+
callMobileMessage('reload')
122+
},
115123
},
116124
}
117125
</script>

0 commit comments

Comments
 (0)