Skip to content

Commit e4a9f1e

Browse files
max-nextcloudbackportbot[bot]
authored andcommitted
fix(sync): send first update without initial document state
Process initial document state as incoming message. This way it will be tracked as received from the remote server by y-websocket and the update send to the server will exclude it. Also use the sync services `opened` event inside WebsocketPolyfill rather than mixing async `syncService.open().then` and event handling. This allows us to emit `opened` and then `sync` from `syncService.open()`. Signed-off-by: Max <max@nextcloud.com>
1 parent a6f16d4 commit e4a9f1e

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

src/services/SyncService.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,7 @@ class SyncService {
268268
this.#outbox.clearSentData(sendable)
269269
const { steps, documentState } = response.data
270270
if (documentState) {
271-
const documentStateStep = documentStateToStep(documentState)
272-
this.bus.emit('sync', {
273-
steps: [documentStateStep],
274-
})
271+
this._emitDocumentStateStep(documentState)
275272
}
276273
this.pushError = 0
277274
this.sending = false

src/services/WebSocketPolyfill.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default function initWebSocketPolyfill(syncService: SyncService, fileId:
2525
onopen?: () => void
2626
#notifyPushBus
2727
#onSync
28+
#onOpened
2829
#processingVersion = 0
2930

3031
constructor(url: string) {
@@ -41,7 +42,6 @@ export default function initWebSocketPolyfill(syncService: SyncService, fileId:
4142
})
4243
}
4344
}
44-
4545
syncService.bus.on('sync', this.#onSync)
4646

4747
syncService.open({ fileId, initialSession }).then((_data) => {

0 commit comments

Comments
 (0)