From 78684e2492162c71d51378db7923c8595509712c Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Sun, 27 Sep 2026 07:52:12 +0200 Subject: [PATCH] fix: keep the last sync time current while the sync settings stay open #34 --- .../settings/device-sync/DeviceSyncAccountRow.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/settings/device-sync/DeviceSyncAccountRow.tsx b/src/components/settings/device-sync/DeviceSyncAccountRow.tsx index a2b35c30..e83b9910 100644 --- a/src/components/settings/device-sync/DeviceSyncAccountRow.tsx +++ b/src/components/settings/device-sync/DeviceSyncAccountRow.tsx @@ -78,6 +78,9 @@ function askReminderOwner(t: TranslateFn): Promise { }); } +/** How often the status line's "… ago" is brought up to date. */ +const RELATIVE_TIME_REFRESH_MS = 30_000; + export function DeviceSyncAccountRow({ account, authority }: Props) { const c = useColors(); const styles = React.useMemo(() => makeStyles(c), [c]); @@ -91,6 +94,12 @@ export function DeviceSyncAccountRow({ account, authority }: Props) { const onInApp = syncOnInApp(entry, authority); const { view, permitted, refresh } = useAndroidSync(entry.androidAccountName, authority); const [busy, setBusy] = React.useState(null); + // "Synced 2 min ago" keeps counting while the settings stay open. + const [now, setNow] = React.useState(() => Date.now()); + React.useEffect(() => { + const timer = setInterval(() => setNow(Date.now()), RELATIVE_TIME_REFRESH_MS); + return () => clearInterval(timer); + }, []); const [prompt, setPrompt] = React.useState(null); const [chooserOpen, setChooserOpen] = React.useState(false); @@ -117,7 +126,7 @@ export function DeviceSyncAccountRow({ account, authority }: Props) { permitted, syncing: !!view?.active, lastRun: entry.lastRun[authority], - now: Date.now(), + now, }, t, );