canvu-react 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/realtime.cjs +0 -26
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.js +0 -26
- package/dist/realtime.js.map +1 -1
- package/package.json +1 -1
package/dist/realtime.cjs
CHANGED
|
@@ -2141,32 +2141,6 @@ function applyServerSnapshotToYDoc(board, options) {
|
|
|
2141
2141
|
const { items: snapshotItems, origin } = options;
|
|
2142
2142
|
const now = Date.now();
|
|
2143
2143
|
board.doc.transact(() => {
|
|
2144
|
-
const snapshotIds = /* @__PURE__ */ new Set();
|
|
2145
|
-
const snapshotById = /* @__PURE__ */ new Map();
|
|
2146
|
-
for (const item of snapshotItems) {
|
|
2147
|
-
const id = getItemId(item);
|
|
2148
|
-
if (!id) continue;
|
|
2149
|
-
snapshotIds.add(id);
|
|
2150
|
-
snapshotById.set(id, item);
|
|
2151
|
-
}
|
|
2152
|
-
const currentIndex = indexYItemsById(board.yItems);
|
|
2153
|
-
const toDeleteIds = [];
|
|
2154
|
-
for (const [id] of currentIndex) {
|
|
2155
|
-
if (snapshotIds.has(id)) continue;
|
|
2156
|
-
if (board.lastServerConfirmedIds.has(id)) {
|
|
2157
|
-
toDeleteIds.push(id);
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2160
|
-
if (toDeleteIds.length > 0) {
|
|
2161
|
-
const refreshed = indexYItemsById(board.yItems);
|
|
2162
|
-
const sortedIndices = toDeleteIds.map((id) => ({ id, index: refreshed.get(id)?.index })).filter(
|
|
2163
|
-
(entry) => entry.index != null
|
|
2164
|
-
).sort((a, b) => b.index - a.index);
|
|
2165
|
-
for (const { id, index } of sortedIndices) {
|
|
2166
|
-
board.yItems.delete(index, 1);
|
|
2167
|
-
board.serverItemSeenAt.delete(id);
|
|
2168
|
-
}
|
|
2169
|
-
}
|
|
2170
2144
|
for (const item of snapshotItems) {
|
|
2171
2145
|
const id = getItemId(item);
|
|
2172
2146
|
if (!id) continue;
|