Skip to content

Commit 276037a

Browse files
committed
fix(mobile): keep wake visits reactive to the clock
1 parent 34ffaaa commit 276037a

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎apps/mobile/src/features/threads/ThreadDetailScreen.tsx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,17 +349,17 @@ function ThreadVisitWatermark(props: {
349349
const lastVisitDispatchRef = useRef({ threadKey: selectedThreadKey, at: 0 });
350350
const selectedThreadId = thread.id;
351351
const snoozedUntil = thread.snoozedUntil;
352-
// A scheduled wake brings no shell update, so re-render when it passes.
353-
const [, setWakeTick] = useState(0);
352+
// Keep the clock in state so React Compiler invalidates the wake calculation.
353+
const [wakeNow, setWakeNow] = useState(() => new Date().toISOString());
354354
useEffect(() => {
355355
if (!showContent || snoozedUntil == null) return;
356356
const delay = Date.parse(snoozedUntil) - Date.now();
357-
if (!(delay > 0)) return;
358-
const timer = setTimeout(() => setWakeTick((tick) => tick + 1), delay);
357+
if (!Number.isFinite(delay)) return;
358+
const timer = setTimeout(() => setWakeNow(new Date().toISOString()), Math.max(0, delay) + 50);
359359
return () => clearTimeout(timer);
360360
}, [showContent, snoozedUntil]);
361361
const selectedThreadWokeAt = threadWokeAt(thread, {
362-
now: new Date().toISOString(),
362+
now: wakeNow,
363363
});
364364
// A scheduled wake can happen without a newer server update.
365365
const selectedThreadUpdatedAt =

0 commit comments

Comments
 (0)