fix(frontend): stop SyncModal polling once sync has finished

It polled /api/sync/status every 1.5s indefinitely even after
in_progress became false and the final result was already shown,
only stopping on unmount (clicking Close). Skip scheduling the next
poll once a fetched status reports the sync is no longer running.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-27 09:01:38 +02:00
parent f7e7b68078
commit 6e01037832

View File

@@ -34,9 +34,14 @@ export function SyncModal({ onClose }: { onClose: () => void }) {
.then((s) => { .then((s) => {
setStatus(s); setStatus(s);
setError(null); setError(null);
// Once a fetched status reports the sync finished, stop polling --
// the final result is already shown, and there's nothing new left
// to fetch until the user starts another sync ("Close" unmounts
// this component, which is the only other way polling stops).
if (!stoppedRef.current && s.in_progress) timeout = setTimeout(tick, 1500);
}) })
.catch((e) => setError(String(e))) .catch((e) => {
.finally(() => { setError(String(e));
if (!stoppedRef.current) timeout = setTimeout(tick, 1500); if (!stoppedRef.current) timeout = setTimeout(tick, 1500);
}); });
}; };