From f17694622c0e536f5d529cfbb029fba45d7c20c9 Mon Sep 17 00:00:00 2001 From: SuperDooper <37051355+superdooper86@users.noreply.github.com> Date: Fri, 8 May 2026 09:34:33 +0200 Subject: [PATCH] fix: persist burn history across launches; show sparkline from first refresh --- ClaudeChecker/UsageViewModel.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ClaudeChecker/UsageViewModel.swift b/ClaudeChecker/UsageViewModel.swift index 8967c35..816b847 100644 --- a/ClaudeChecker/UsageViewModel.swift +++ b/ClaudeChecker/UsageViewModel.swift @@ -37,6 +37,9 @@ class UsageViewModel: ObservableObject { let saved = UserDefaults.standard.double(forKey: "refresh_interval") refreshInterval = saved > 0 ? saved : 60 showInMenuBar = UserDefaults.standard.object(forKey: "show_in_menubar") as? Bool ?? true + if let saved = UserDefaults.standard.object(forKey: "burn_history") as? [String: [Double]] { + burnHistoryStore = saved + } loadPlaceholderData() } @@ -84,8 +87,9 @@ class UsageViewModel: ObservableObject { history.append(limits[i].usedPercent) if history.count > maxHistorySamples { history.removeFirst() } burnHistoryStore[key] = history - if history.count > 1 { limits[i].burnHistory = history } + limits[i].burnHistory = history } + UserDefaults.standard.set(burnHistoryStore, forKey: "burn_history") checkLimitNotifications(for: limits) } catch AppError.notAuthenticated { isNotAuthenticated = true @@ -313,3 +317,4 @@ extension Notification.Name { static let limitReset = Notification.Name("limitReset") static let openUpdateSheet = Notification.Name("openUpdateSheet") } +