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.js CHANGED
@@ -2482,6 +2482,17 @@ function useRealtimeSession(options) {
2482
2482
  }
2483
2483
  const board = boardRef.current;
2484
2484
  if (board) {
2485
+ if (!options2?.replace) {
2486
+ const pendingLocal = pendingLocalItemsRef.current;
2487
+ if (pendingLocal) {
2488
+ pendingLocalItemsRef.current = null;
2489
+ applyLocalItemsToYDoc(board, {
2490
+ items: pendingLocal,
2491
+ origin: ORIGIN_LOCAL
2492
+ });
2493
+ queuedDirtyRef.current = true;
2494
+ }
2495
+ }
2485
2496
  if (options2?.replace) {
2486
2497
  replaceYDocWithSnapshot(board, {
2487
2498
  items: snapshot.items,
@@ -3477,6 +3488,7 @@ function useRealtimeCanvasDocument(options) {
3477
3488
  const [loading, setLoading] = useState(false);
3478
3489
  const lastAppliedRevisionRef = useRef(null);
3479
3490
  const inFlightRevisionRef = useRef(null);
3491
+ const hasEverPropagatedItemsRef = useRef(false);
3480
3492
  const realtimeEnabled = enabled && session != null;
3481
3493
  const documentRevision = session?.document?.revision ?? null;
3482
3494
  const documentItems = session?.document?.items;
@@ -3515,6 +3527,12 @@ function useRealtimeCanvasDocument(options) {
3515
3527
  if (cancelled) return;
3516
3528
  if (inFlightRevisionRef.current !== documentRevision) return;
3517
3529
  lastAppliedRevisionRef.current = documentRevision;
3530
+ if (resolvedItems.length === 0 && hasEverPropagatedItemsRef.current) {
3531
+ return;
3532
+ }
3533
+ if (resolvedItems.length > 0) {
3534
+ hasEverPropagatedItemsRef.current = true;
3535
+ }
3518
3536
  onItemsChange(resolvedItems);
3519
3537
  }).finally(() => {
3520
3538
  if (inFlightRevisionRef.current === documentRevision) {