canvu-react 0.4.2 → 0.4.4
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 +18 -0
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.js +18 -0
- 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,
|
|
@@ -3502,6 +3513,7 @@ function useRealtimeCanvasDocument(options) {
|
|
|
3502
3513
|
const [loading, setLoading] = react.useState(false);
|
|
3503
3514
|
const lastAppliedRevisionRef = react.useRef(null);
|
|
3504
3515
|
const inFlightRevisionRef = react.useRef(null);
|
|
3516
|
+
const hasEverPropagatedItemsRef = react.useRef(false);
|
|
3505
3517
|
const realtimeEnabled = enabled && session != null;
|
|
3506
3518
|
const documentRevision = session?.document?.revision ?? null;
|
|
3507
3519
|
const documentItems = session?.document?.items;
|
|
@@ -3540,6 +3552,12 @@ function useRealtimeCanvasDocument(options) {
|
|
|
3540
3552
|
if (cancelled) return;
|
|
3541
3553
|
if (inFlightRevisionRef.current !== documentRevision) return;
|
|
3542
3554
|
lastAppliedRevisionRef.current = documentRevision;
|
|
3555
|
+
if (resolvedItems.length === 0 && hasEverPropagatedItemsRef.current) {
|
|
3556
|
+
return;
|
|
3557
|
+
}
|
|
3558
|
+
if (resolvedItems.length > 0) {
|
|
3559
|
+
hasEverPropagatedItemsRef.current = true;
|
|
3560
|
+
}
|
|
3543
3561
|
onItemsChange(resolvedItems);
|
|
3544
3562
|
}).finally(() => {
|
|
3545
3563
|
if (inFlightRevisionRef.current === documentRevision) {
|