Skip to content

Commit 392a5a2

Browse files
committed
Show the bank-sync notice only when Synci is behind, and make it more visible
1 parent d8c9b75 commit 392a5a2

2 files changed

Lines changed: 11 additions & 16 deletions

File tree

src/components/dashboard/synci-status.tsx

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ import { Clock } from "lucide-react";
66
import { formatDistanceToNow } from "date-fns";
77
import { fi as fiFns, enUS } from "date-fns/locale";
88

9-
// Passive heads-up when Synci is the data source (local mode): how long ago the bank last synced,
10-
// plus weekend context, since bank postings lag and the displayed balances can trail reality.
9+
// Heads-up when Synci is the data source (local mode) and the bank sync is actually behind. Synci
10+
// normally runs every 30 minutes and a no-op sync still refreshes the timestamp, so this stays
11+
// hidden while syncing works - it only appears when transactions genuinely are not coming in.
12+
const STALE_HOURS = 3;
13+
1114
export function SynciStatus() {
1215
const { locale } = useLocale();
1316
const [info, setInfo] = useState<{ mode: string; synci: boolean; lastSync: string | null } | null>(null);
@@ -23,27 +26,19 @@ export function SynciStatus() {
2326

2427
if (!info || info.mode !== "local" || !info.synci) return null;
2528

26-
const day = new Date().getDay();
27-
const isWeekend = day === 0 || day === 6;
2829
const last = info.lastSync ? new Date(info.lastSync) : null;
2930
const hoursSince = last ? (Date.now() - last.getTime()) / 3600000 : Infinity;
30-
31-
// Only surface this when it's actually informative: on weekends (bank postings lag) or when the
32-
// last sync is getting old. On a normal weekday with the 30-minute timer it stays hidden.
33-
if (!isWeekend && hoursSince < 6) return null;
31+
if (hoursSince < STALE_HOURS) return null;
3432

3533
const ago = last ? formatDistanceToNow(last, { addSuffix: false, locale: locale === "fi" ? fiFns : enUS }) : null;
36-
const syncLine = ago
37-
? (locale === "fi" ? `Viimeisin pankkisynkronointi ${ago} sitten.` : `Last bank sync was ${ago} ago.`)
34+
const text = ago
35+
? (locale === "fi" ? `Pankki synkronoitu viimeksi ${ago} sitten. Tapahtumia voi puuttua, tarkista että kaikki on lisätty.` : `Bank last synced ${ago} ago. Some transactions may be missing - check everything is added.`)
3836
: (locale === "fi" ? "Pankkia ei ole vielä synkronoitu." : "No bank sync yet.");
39-
const weekendLine = isWeekend
40-
? (locale === "fi" ? " Viikonloppu - osa tapahtumista voi olla vielä kirjautumatta pankissa." : " It's the weekend, so some transactions may still be pending at the bank.")
41-
: "";
4237

4338
return (
4439
<div className="synci-status">
4540
<Clock className="synci-status-icon" />
46-
<p className="synci-status-text">{syncLine}{weekendLine}</p>
41+
<p className="synci-status-text">{text}</p>
4742
</div>
4843
);
4944
}

src/styles/modules/entry-reminder.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@
100100
gap: 0.625rem;
101101
padding: 0.625rem 0.75rem;
102102
border-radius: var(--radius);
103-
background: color-mix(in srgb, var(--muted) 35%, transparent);
104-
border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
103+
background: color-mix(in srgb, var(--muted) 85%, transparent);
104+
border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
105105
}
106106

107107
.synci-status-icon {

0 commit comments

Comments
 (0)