Task #353: Fix current-meeting highlight sticking after device sleep

The green highlight on the currently-in-progress meeting row would get
stuck when the user locked their iPad, switched apps, or the device
slept. The 60-second setInterval timer that drives `nowTick` is frozen
by the browser during background/sleep states. When the user returned,
the timer wouldn't fire immediately, leaving the highlight on the
old meeting.

Fix: Added a `visibilitychange` event listener alongside the existing
interval timer. When the document becomes visible again, it immediately
calls `setNowTick(Date.now())`, which triggers `computeCurrentMeetingId`
to re-evaluate via the existing useMemo dependency. The listener is
properly cleaned up in the effect's return function.

Changed file:
- artifacts/tx-os/src/pages/executive-meetings.tsx (lines 1065-1084)
This commit is contained in:
Riyadh
2026-05-04 06:51:50 +00:00
parent 1f9adc7b82
commit 1290dd5bc5
@@ -1067,9 +1067,16 @@ function ScheduleSection({
setNowTick(Date.now());
intervalId = setInterval(() => setNowTick(Date.now()), 60_000);
}, msToNextMinute);
const onVisibilityChange = () => {
if (document.visibilityState === "visible") {
setNowTick(Date.now());
}
};
document.addEventListener("visibilitychange", onVisibilityChange);
return () => {
clearTimeout(timeoutId);
if (intervalId) clearInterval(intervalId);
document.removeEventListener("visibilitychange", onVisibilityChange);
};
}, []);