diff --git a/Sources/CalendarrCore/Snapshot/SnapshotModels.swift b/Sources/CalendarrCore/Snapshot/SnapshotModels.swift index 476c1e6..47762cc 100644 --- a/Sources/CalendarrCore/Snapshot/SnapshotModels.swift +++ b/Sources/CalendarrCore/Snapshot/SnapshotModels.swift @@ -79,6 +79,12 @@ public struct SnapshotTheme: Sendable, Hashable { public let line: String public let primary: String public let accent: String + + public init(today: String, text: String, background: String, + line: String, primary: String, accent: String) { + self.today = today; self.text = text; self.background = background + self.line = line; self.primary = primary; self.accent = accent + } } // MARK: - Snapshot diff --git a/Sources/CalendarrCore/Snapshot/SnapshotStore.swift b/Sources/CalendarrCore/Snapshot/SnapshotStore.swift index a9eb339..9c59763 100644 --- a/Sources/CalendarrCore/Snapshot/SnapshotStore.swift +++ b/Sources/CalendarrCore/Snapshot/SnapshotStore.swift @@ -59,7 +59,17 @@ public struct SnapshotStore: Sendable { } let url = container.appendingPathComponent(Self.cacheFilename) - guard FileManager.default.fileExists(atPath: url.path) else { return .neverWritten } + guard FileManager.default.fileExists(atPath: url.path) else { + // No cache. Signing out deletes the events — keeping them would leak + // the previous user's calendar — so the session file is what tells + // "signed out" apart from "never ran here". Answering that in one + // call keeps every consumer from reimplementing the distinction. + if let session = SharedSessionStore(appGroupID: appGroupID).read(), + !session.isLoggedIn { + return .loggedOut(writtenAt: session.writtenAt) + } + return .neverWritten + } let data: Data do { data = try Data(contentsOf: url) }