type._map points to the last element instead to enable merging of deletes in Map

This commit is contained in:
Kevin Jahns
2019-04-10 21:01:59 +02:00
parent 654510f3ff
commit 9fe47e98d5
5 changed files with 58 additions and 73 deletions

View File

@@ -190,6 +190,10 @@ export const transact = (y, f) => {
if (left.deleted === right.deleted && left.constructor === right.constructor) {
if (left.mergeWith(right)) {
structs.splice(pos, 1)
if (right instanceof AbstractItem && right.parentSub !== null && right.parent._map.get(right.parentSub) === right) {
// @ts-ignore we already did a constructor check above
right.parent._map.set(right.parentSub, left)
}
}
}
}
@@ -210,6 +214,7 @@ export const transact = (y, f) => {
}
}
// try to merge replacedItems
// TODO: replacedItems should hold ids
for (const replacedItem of transaction._replacedItems) {
const id = replacedItem.id
const client = id.client