canvu-react 0.4.1 → 0.4.3
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 +15 -5
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.js +15 -5
- package/dist/realtime.js.map +1 -1
- package/package.json +1 -1
package/dist/realtime.cjs
CHANGED
|
@@ -2507,6 +2507,17 @@ function useRealtimeSession(options) {
|
|
|
2507
2507
|
}
|
|
2508
2508
|
const board = boardRef.current;
|
|
2509
2509
|
if (board) {
|
|
2510
|
+
if (!options2?.replace) {
|
|
2511
|
+
const pendingLocal = pendingLocalItemsRef.current;
|
|
2512
|
+
if (pendingLocal) {
|
|
2513
|
+
pendingLocalItemsRef.current = null;
|
|
2514
|
+
applyLocalItemsToYDoc(board, {
|
|
2515
|
+
items: pendingLocal,
|
|
2516
|
+
origin: ORIGIN_LOCAL
|
|
2517
|
+
});
|
|
2518
|
+
queuedDirtyRef.current = true;
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2510
2521
|
if (options2?.replace) {
|
|
2511
2522
|
replaceYDocWithSnapshot(board, {
|
|
2512
2523
|
items: snapshot.items,
|
|
@@ -2555,7 +2566,10 @@ function useRealtimeSession(options) {
|
|
|
2555
2566
|
removeRealtimeOfflineDraft(roomId);
|
|
2556
2567
|
return;
|
|
2557
2568
|
}
|
|
2558
|
-
|
|
2569
|
+
const board = boardRef.current;
|
|
2570
|
+
const draft = localDraftRef.current;
|
|
2571
|
+
const draftToWrite = board && draft.yDocState == null ? { ...draft, yDocState: encodeYDocState(board) } : draft;
|
|
2572
|
+
writeRealtimeOfflineDraft(draftToWrite);
|
|
2559
2573
|
}, [clearDraftPersistSchedule, roomId]);
|
|
2560
2574
|
const scheduleDraftPersistence = react.useCallback(() => {
|
|
2561
2575
|
clearDraftPersistSchedule();
|
|
@@ -2674,7 +2688,6 @@ function useRealtimeSession(options) {
|
|
|
2674
2688
|
baseRevision,
|
|
2675
2689
|
items: mergedItems,
|
|
2676
2690
|
updatedAt: nowMs(),
|
|
2677
|
-
yDocState: encodeYDocState(board),
|
|
2678
2691
|
pendingIds: Array.from(pendingIds)
|
|
2679
2692
|
});
|
|
2680
2693
|
scheduleDraftPersistenceRef.current?.();
|
|
@@ -2782,7 +2795,6 @@ function useRealtimeSession(options) {
|
|
|
2782
2795
|
baseRevision: serverDocument.revision,
|
|
2783
2796
|
items: mergedItems,
|
|
2784
2797
|
updatedAt: nowMs(),
|
|
2785
|
-
yDocState: encodeYDocState(board),
|
|
2786
2798
|
pendingIds: Array.from(pendingIds)
|
|
2787
2799
|
});
|
|
2788
2800
|
outboundInFlightRef.current = null;
|
|
@@ -3097,7 +3109,6 @@ function useRealtimeSession(options) {
|
|
|
3097
3109
|
baseRevision: currentRevisionRef.current,
|
|
3098
3110
|
items: mergedItems,
|
|
3099
3111
|
updatedAt: nowMs(),
|
|
3100
|
-
yDocState: board ? encodeYDocState(board) : void 0,
|
|
3101
3112
|
pendingIds: board ? Array.from(getLocallyPendingItemIds(board)) : void 0
|
|
3102
3113
|
});
|
|
3103
3114
|
queuedDirtyRef.current = true;
|
|
@@ -3213,7 +3224,6 @@ function useRealtimeSession(options) {
|
|
|
3213
3224
|
baseRevision: currentRevisionRef.current,
|
|
3214
3225
|
items: mergedItems,
|
|
3215
3226
|
updatedAt: nowMs(),
|
|
3216
|
-
yDocState: encodeYDocState(board),
|
|
3217
3227
|
pendingIds: Array.from(pendingIds)
|
|
3218
3228
|
});
|
|
3219
3229
|
}
|