Skip to content

Commit

Permalink
Merge pull request #11 from ajhyndman/transact-init
Browse files Browse the repository at this point in the history
Wrap initial update syncing in a Doc transaction
  • Loading branch information
dmonad authored Jul 27, 2020
2 parents f179726 + ad231d4 commit 795b5b6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/y-indexeddb.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export const fetchUpdates = idbPersistence => {
const [updatesStore] = idb.transact(/** @type {IDBDatabase} */ (idbPersistence.db), [updatesStoreName]) // , 'readonly')
return idb.getAll(updatesStore, idb.createIDBKeyRangeLowerBound(idbPersistence._dbref, false)).then(updates =>
idbPersistence._mux(() =>
updates.forEach(val => Y.applyUpdate(idbPersistence.doc, val))
idbPersistence.doc.transact(() =>
updates.forEach(val => Y.applyUpdate(idbPersistence.doc, val))
)
)
)
.then(() => idb.getLastKey(updatesStore).then(lastKey => { idbPersistence._dbref = lastKey + 1 }))
Expand Down

0 comments on commit 795b5b6

Please sign in to comment.