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
fix(sync): process document state from push response
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 <[email protected]>
  • Loading branch information
max-nextcloud committed Nov 25, 2024
commit 3bc7015fe06b98770138bdf0d3be823493fc64b9
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
Loading