Skip to content

Commit

Permalink
fix(sync): process document state from push response
Browse files Browse the repository at this point in the history
Do not process document state from create response.
During create the editor has not been initialized fully
and the cursor position is 0 - which is invalid
as it is not inside a node with inline content.
(It is inside the doc before the initial paragraph.)

This also allows processing document state later on
in order to recover from out of sync situations.
But we do not make use of that yet.

Signed-off-by: Max <max@nextcloud.com>
  • Loading branch information
max-nextcloud committed Nov 18, 2024
1 parent 620ac7a commit f08a168
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/services/SyncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,6 @@ class SyncService {
this.baseVersionEtag = this.#connection.document.baseVersionEtag
this.emit('opened', this.connectionState)
this.emit('loaded', this.connectionState)
const documentState = this.connectionState.documentState
if (documentState) {
const initialStep = documentStateToStep(documentState)
this.emit('sync', {
version: this.version,
steps: [initialStep],
document: this.#connection.document,
})
}

return this.connectionState
}

Expand Down Expand Up @@ -186,7 +176,15 @@ class SyncService {
}
return this.#connection.push(sendable)
.then((response) => {
const { steps } = response.data
const { steps, documentState } = response.data
if (documentState) {
const documentStateStep = documentStateToStep(documentState)
this.emit('sync', {
version: this.version,
steps: [documentStateStep],
document: this.#connection.document,
})
}
this.pushError = 0
this.sending = false
if (steps?.length > 0) {
Expand Down

0 comments on commit f08a168

Please sign in to comment.