Skip to content

Commit f08a168

Browse files
committed
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 <max@nextcloud.com>
1 parent 620ac7a commit f08a168

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

src/services/SyncService.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,6 @@ class SyncService {
122122
this.baseVersionEtag = this.#connection.document.baseVersionEtag
123123
this.emit('opened', this.connectionState)
124124
this.emit('loaded', this.connectionState)
125-
const documentState = this.connectionState.documentState
126-
if (documentState) {
127-
const initialStep = documentStateToStep(documentState)
128-
this.emit('sync', {
129-
version: this.version,
130-
steps: [initialStep],
131-
document: this.#connection.document,
132-
})
133-
}
134-
135125
return this.connectionState
136126
}
137127

@@ -186,7 +176,15 @@ class SyncService {
186176
}
187177
return this.#connection.push(sendable)
188178
.then((response) => {
189-
const { steps } = response.data
179+
const { steps, documentState } = response.data
180+
if (documentState) {
181+
const documentStateStep = documentStateToStep(documentState)
182+
this.emit('sync', {
183+
version: this.version,
184+
steps: [documentStateStep],
185+
document: this.#connection.document,
186+
})
187+
}
190188
this.pushError = 0
191189
this.sending = false
192190
if (steps?.length > 0) {

0 commit comments

Comments
 (0)