mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-04-30 07:59:45 +00:00
Fix menubar crashes and add reliable auto-refresh
Fixes crash when switching timeframes or providers by handling duplicate dates in history data gracefully. Adds LaunchAgent that posts a distributed notification every 15 seconds to keep prices fresh even after long idle periods.
This commit is contained in:
parent
17b7e6ae6c
commit
68daad5dfa
3 changed files with 67 additions and 3 deletions
|
|
@ -399,7 +399,7 @@ private func buildTrendBars(from days: [DailyHistoryEntry]) -> [TrendBar] {
|
|||
f.timeZone = .current
|
||||
return f
|
||||
}()
|
||||
let entryByDate = Dictionary(uniqueKeysWithValues: days.map { ($0.date, $0) })
|
||||
let entryByDate = Dictionary(days.map { ($0.date, $0) }, uniquingKeysWith: { _, new in new })
|
||||
let today = calendar.startOfDay(for: Date())
|
||||
let todayKey = formatter.string(from: today)
|
||||
|
||||
|
|
@ -837,7 +837,7 @@ private func computeAllStats(payload: MenubarPayload) -> AllStats {
|
|||
peakDaySpend = "—"
|
||||
}
|
||||
|
||||
let costByDate = Dictionary(uniqueKeysWithValues: history.map { ($0.date, $0.cost) })
|
||||
let costByDate = Dictionary(history.map { ($0.date, $0.cost) }, uniquingKeysWith: +)
|
||||
|
||||
var currentStreak = 0
|
||||
for offset in 0..<400 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue