From 759ecb21f7caf6b56ba990276ad6f60543f1eeab Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Thu, 11 Apr 2019 00:31:43 +0200 Subject: [PATCH] rename transaction._replacedItems to transaction._mergeStructs --- src/structs/AbstractItem.js | 4 ++-- src/structs/ItemType.js | 2 -- src/utils/Transaction.js | 16 +++++++--------- src/utils/structEncoding.js | 1 - tests/y-array.tests.js | 2 -- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/structs/AbstractItem.js b/src/structs/AbstractItem.js index e76b8547..2f619c95 100644 --- a/src/structs/AbstractItem.js +++ b/src/structs/AbstractItem.js @@ -56,7 +56,7 @@ export const splitItem = (transaction, leftItem, diff) => { rightItem.right.left = rightItem } // right is more specific. - transaction._replacedItems.add(rightItem) + transaction._mergeStructs.add(rightItem.id) return rightItem } @@ -430,7 +430,7 @@ export class AbstractItem extends AbstractStruct { } } replaceStruct(store, this, r) - transaction._replacedItems.add(r) + transaction._mergeStructs.add(r.id) } /** diff --git a/src/structs/ItemType.js b/src/structs/ItemType.js index 67c11e90..5a2cf33c 100644 --- a/src/structs/ItemType.js +++ b/src/structs/ItemType.js @@ -2,8 +2,6 @@ * @module structs */ -// TODO: ItemBinary should be able to merge with right (similar to other items). Or the other items (ItemJSON) should not be able to merge - extra byte + consistency - import { AbstractItem, AbstractItemRef, diff --git a/src/utils/Transaction.js b/src/utils/Transaction.js index 17441505..97c52539 100644 --- a/src/utils/Transaction.js +++ b/src/utils/Transaction.js @@ -14,7 +14,7 @@ import { callEventHandlerListeners, AbstractItem, ItemDeleted, - AbstractType, AbstractStruct, YEvent, Y // eslint-disable-line + ID, AbstractType, AbstractStruct, YEvent, Y // eslint-disable-line } from '../internals.js' import * as encoding from 'lib0/encoding.js' @@ -86,9 +86,9 @@ export class Transaction { */ this._updateMessage = null /** - * @type {Set} + * @type {Set} */ - this._replacedItems = new Set() + this._mergeStructs = new Set() } /** * @type {encoding.Encoder|null} @@ -213,12 +213,10 @@ 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 - const clock = id.clock + // try to merge mergeStructs + for (const mid of transaction._mergeStructs) { + const client = mid.client + const clock = mid.clock /** * @type {Array} */ diff --git a/src/utils/structEncoding.js b/src/utils/structEncoding.js index cd86cb42..a82a865e 100644 --- a/src/utils/structEncoding.js +++ b/src/utils/structEncoding.js @@ -148,7 +148,6 @@ export const readClientsStructRefs = decoder => { * @param {Transaction} transaction * @param {StructStore} store * - * @todo reimplement without iterators - read everything in arrays instead */ const resumeStructIntegration = (transaction, store) => { const stack = store.pendingStack diff --git a/tests/y-array.tests.js b/tests/y-array.tests.js index 06c7d5e5..3953a883 100644 --- a/tests/y-array.tests.js +++ b/tests/y-array.tests.js @@ -306,8 +306,6 @@ const arrayTransactions = [ } ] -// TODO: http://127.0.0.1:3443/?filter=\[22/&seed=1943600076 - /** * @param {t.TestCase} tc */