diff --git a/docs/pages/ready-made-features/multiplayer/sync-engine/liveblocks-storage.mdx b/docs/pages/ready-made-features/multiplayer/sync-engine/liveblocks-storage.mdx index 0d5b56f81c..ca677c360d 100644 --- a/docs/pages/ready-made-features/multiplayer/sync-engine/liveblocks-storage.mdx +++ b/docs/pages/ready-made-features/multiplayer/sync-engine/liveblocks-storage.mdx @@ -16,7 +16,7 @@ maintenance for you. -Our [interactive React tutorial](/tutorial/react/storage) guides you through +Our [interactive React tutorial](/docs/tutorial/react/getting-started/storage) guides you through using each of the concepts listed on this page. diff --git a/packages/liveblocks-server/src/YjsStorage.ts b/packages/liveblocks-server/src/YjsStorage.ts index 819922699b..da8f7e8c54 100644 --- a/packages/liveblocks-server/src/YjsStorage.ts +++ b/packages/liveblocks-server/src/YjsStorage.ts @@ -248,11 +248,13 @@ export class YjsStorage { doc: Y.Doc, docId: YDocId ): Promise => { - const storedKeys: string[] = []; - for (const [key, update] of await this.driver.iter_y_updates(docId)) { - Y.applyUpdate(doc, update); - storedKeys.push(key); - } + const docUpdates = Object.fromEntries( + await this.driver.iter_y_updates(docId) + ); + const updates = Object.values(docUpdates); + const newupdate = Y.mergeUpdates(updates); + const storedKeys = Object.keys(docUpdates); + Y.applyUpdate(doc, newupdate); // after compaction, there will only be one unique key. if (this.shouldCompact(storedKeys)) { await this._compactYJSUpdates(doc, docId, storedKeys);