Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
🧑‍💻 (#2462): proxy some sync service events
Signed-off-by: Vinicius Reis <[email protected]>
  • Loading branch information
Vinicius Reis authored and mejo- committed Jul 6, 2022
commit cbe5ae4861f07f00e74ca3f1ad9fb9948bb23dd5
21 changes: 21 additions & 0 deletions src/components/EditorWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ export default {
.on('error', this.onError)
.on('stateChange', this.onStateChange)
.on('idle', this.onIdle)
.on('save', this.onSave)
},

unlistenSyncServiceEvents() {
Expand All @@ -383,6 +384,7 @@ export default {
.off('error', this.onError)
.off('stateChange', this.onStateChange)
.off('idle', this.onIdle)
.off('save', this.onSave)
},

resolveUseThisVersion() {
Expand Down Expand Up @@ -630,6 +632,9 @@ export default {
})
this.$syncService.state = this.$editor.state
this.updateLastSavedStatus()
this.$nextTick(() => {
this.$emit('sync-service:sync')
})
} catch (e) {
console.error('Failed to update steps in collaboration plugin', e)
// TODO: we should recreate the editing session when this happens
Expand All @@ -639,6 +644,11 @@ export default {

onError({ type, data }) {
this.$editor.setOptions({ editable: false })

this.$nextTick(() => {
this.$emit('sync-service:error')
})

if (type === ERROR_TYPE.SAVE_COLLISSION && (!this.syncError || this.syncError.type !== ERROR_TYPE.SAVE_COLLISSION)) {
this.contentLoaded = true
this.syncError = {
Expand Down Expand Up @@ -667,6 +677,7 @@ export default {
this.$editor.commands.focus()
}
this.$emit('ready')
// TODO: remove $parent access
this.$parent.$emit('ready', true)
}
if (Object.prototype.hasOwnProperty.call(state, 'dirty')) {
Expand All @@ -679,6 +690,16 @@ export default {
this.idle = true
this.readOnly = true
this.$editor.setOptions({ editable: !this.readOnly })

this.$nextTick(() => {
this.$emit('sync-service:idle')
})
},

onSave() {
this.$nextTick(() => {
this.$emit('sync-service:save')
})
},

async close() {
Expand Down