mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-05-01 16:30:15 +00:00
fix(menubar): prefetch periods and align dashboard dates with local timezone
Loading overlay no longer flashes on every 15s poll. isLoading now only toggles when the cache is cold, and all periods prefetch once on launch so tab switching is instant. Heatmap tooltip, trend bars, forecast, and all-time stats were computing on UTC dates while the CLI reports on local dates, so the two disagreed at day boundaries. Switched every date formatter and calendar in these paths to .current so the menubar matches codeburn today output.
This commit is contained in:
parent
988060cd09
commit
3c2aab2207
3 changed files with 35 additions and 21 deletions
|
|
@ -73,10 +73,11 @@ final class AppStore {
|
|||
let key = currentKey
|
||||
guard !inFlightKeys.contains(key) else { return }
|
||||
inFlightKeys.insert(key)
|
||||
isLoading = true
|
||||
let showLoading = cache[key] == nil
|
||||
if showLoading { isLoading = true }
|
||||
defer {
|
||||
inFlightKeys.remove(key)
|
||||
isLoading = false
|
||||
if showLoading { isLoading = false }
|
||||
}
|
||||
do {
|
||||
let fresh = try await DataClient.fetch(period: key.period, provider: key.provider, includeOptimize: includeOptimize)
|
||||
|
|
@ -88,6 +89,15 @@ final class AppStore {
|
|||
}
|
||||
}
|
||||
|
||||
/// Prefetch all periods so tab switching is instant. Skips any period already cached.
|
||||
func prefetchAll() async {
|
||||
for period in Period.allCases {
|
||||
let key = PayloadCacheKey(period: period, provider: .all)
|
||||
if cache[key] != nil { continue }
|
||||
await refreshQuietly(period: period)
|
||||
}
|
||||
}
|
||||
|
||||
/// Background refresh for a period other than the visible one (e.g. keeping today fresh for the menubar badge).
|
||||
/// Does not toggle isLoading, so the popover's loading overlay is unaffected.
|
||||
/// Always uses the .all provider since the menubar badge shows total spend.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue