diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index e221381..3c05aa9 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -163,6 +163,8 @@ function Welcome({ onSignIn }: { onSignIn: () => void }) { function Dashboard({ user, onExpired }: { user: PublicUser; onExpired: () => void }) { const [today, setToday] = useState(null); + const todaySnapshot = useRef(today); + todaySnapshot.current = today; const [error, setError] = useState(""); const [revision, setRevision] = useState(0); const [habitRevisions, setHabitRevisions] = useState>({}); @@ -204,9 +206,10 @@ function Dashboard({ user, onExpired }: { user: PublicUser; onExpired: () => voi habitRequest("/today", { signal: controller.signal }) .then((data) => { if (!controller.signal.aborted) { - setToday(current => reconcileToday(current, data)); + const next = reconcileToday(todaySnapshot.current, data); + setToday(next); setNeedsRefresh(false); - setRevision((value) => value + 1); + if (next !== todaySnapshot.current) setRevision((value) => value + 1); } }) .catch((error) => {