diff --git a/frontend/src/components/SyncStatus.tsx b/frontend/src/components/SyncStatus.tsx index 56bbb19..39b133d 100644 --- a/frontend/src/components/SyncStatus.tsx +++ b/frontend/src/components/SyncStatus.tsx @@ -1,7 +1,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { useTranslation } from "react-i18next"; import { Clock, Database, History, Loader2, Pause, Play } from "lucide-react"; -import { api } from "../lib/api"; +import { api, type MyStatus } from "../lib/api"; import { formatViews } from "../lib/format"; import Tooltip from "./Tooltip"; @@ -22,11 +22,19 @@ export default function SyncStatus({ queryFn: api.myStatus, // Track the scheduler near-real-time: poll even when the tab is backgrounded, and // refresh immediately on tab focus (the global default disables focus refetch), so the - // "N without full history" count keeps ticking down without a manual reload. - refetchInterval: 30_000, + // "N without full history" count keeps ticking down without a manual reload. Poll faster + // while a job is running or work is pending — so the live "syncing" state is actually + // caught — and ease back to a slow idle tick once everything's settled. + refetchInterval: (query) => { + const d = query.state.data as MyStatus | undefined; + const busy = + !!d && + (d.sync_active || d.channels_recent_pending > 0 || d.channels_deep_pending > 0); + return busy ? 8_000 : 30_000; + }, refetchIntervalInBackground: true, refetchOnWindowFocus: true, - staleTime: 25_000, + staleTime: 5_000, }); const toggle = useMutation({