diff --git a/src/services/SyncService.js b/src/services/SyncService.js index 5c0c50f9f19..e31e51804e8 100644 --- a/src/services/SyncService.js +++ b/src/services/SyncService.js @@ -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 } @@ -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) {