Compare origin ids in item.integrate

This commit is contained in:
Kevin Jahns
2019-04-06 15:55:20 +02:00
parent 1b17b5e400
commit c635963747
5 changed files with 36 additions and 9 deletions

View File

@@ -125,6 +125,16 @@ export const find = (store, id) => {
return structs[findIndexSS(structs, id.clock)]
}
/**
* Expects that id is actually in store. This function throws or is an infinite loop otherwise.
*
* @param {StructStore} store
* @param {ID} id
* @return {AbstractItem}
*/
// @ts-ignore
export const getItem = (store, id) => find(store, id)
/**
* Expects that id is actually in store. This function throws or is an infinite loop otherwise.
*

View File

@@ -95,16 +95,16 @@ export class Y extends Observable {
callEventHandlerListeners(type._dEH, [events, transaction])
})
// only call afterTransaction listeners if anything changed
const transactionChangedContent = transaction.changedParentTypes.size !== 0
const transactionChangedContent = transaction.changedParentTypes.size > 0 || transaction.deleteSet.clients.size > 0
if (transactionChangedContent) {
transaction.afterState = getStates(transaction.y.store)
// when all changes & events are processed, emit afterTransaction event
this.emit('afterTransaction', [this, transaction])
// transaction cleanup
const store = transaction.y.store
const ds = transaction.deleteSet
// replace deleted items with ItemDeleted / GC
sortAndMergeDeleteSet(ds)
this.emit('afterTransaction', [this, transaction])
/**
* @type {Set<ItemDeleted|GC>}
*/