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.js
CHANGED
|
@@ -2116,32 +2116,6 @@ function applyServerSnapshotToYDoc(board, options) {
|
|
|
2116
2116
|
const { items: snapshotItems, origin } = options;
|
|
2117
2117
|
const now = Date.now();
|
|
2118
2118
|
board.doc.transact(() => {
|
|
2119
|
-
const snapshotIds = /* @__PURE__ */ new Set();
|
|
2120
|
-
const snapshotById = /* @__PURE__ */ new Map();
|
|
2121
|
-
for (const item of snapshotItems) {
|
|
2122
|
-
const id = getItemId(item);
|
|
2123
|
-
if (!id) continue;
|
|
2124
|
-
snapshotIds.add(id);
|
|
2125
|
-
snapshotById.set(id, item);
|
|
2126
|
-
}
|
|
2127
|
-
const currentIndex = indexYItemsById(board.yItems);
|
|
2128
|
-
const toDeleteIds = [];
|
|
2129
|
-
for (const [id] of currentIndex) {
|
|
2130
|
-
if (snapshotIds.has(id)) continue;
|
|
2131
|
-
if (board.lastServerConfirmedIds.has(id)) {
|
|
2132
|
-
toDeleteIds.push(id);
|
|
2133
|
-
}
|
|
2134
|
-
}
|
|
2135
|
-
if (toDeleteIds.length > 0) {
|
|
2136
|
-
const refreshed = indexYItemsById(board.yItems);
|
|
2137
|
-
const sortedIndices = toDeleteIds.map((id) => ({ id, index: refreshed.get(id)?.index })).filter(
|
|
2138
|
-
(entry) => entry.index != null
|
|
2139
|
-
).sort((a, b) => b.index - a.index);
|
|
2140
|
-
for (const { id, index } of sortedIndices) {
|
|
2141
|
-
board.yItems.delete(index, 1);
|
|
2142
|
-
board.serverItemSeenAt.delete(id);
|
|
2143
|
-
}
|
|
2144
|
-
}
|
|
2145
2119
|
for (const item of snapshotItems) {
|
|
2146
2120
|
const id = getItemId(item);
|
|
2147
2121
|
if (!id) continue;
|