diff options
Diffstat (limited to 'octosentry/SecurityEventStore.swift')
| -rw-r--r-- | octosentry/SecurityEventStore.swift | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/octosentry/SecurityEventStore.swift b/octosentry/SecurityEventStore.swift index 65a7280..26dcc16 100644 --- a/octosentry/SecurityEventStore.swift +++ b/octosentry/SecurityEventStore.swift @@ -28,6 +28,10 @@ final class SecurityEventStore { private(set) var watchedRepos: [String] = [] private(set) var watchListErrorMessage: String? + var unseenCriticalCount: Int { + rawEvents.filter { $0.severity == .critical && !$0.seenLocally }.count + } + private let persistenceStore = PersistenceStore() private var rawEvents: [SecurityEvent] = [] private var pollingTask: Task<Void, Never>? @@ -130,6 +134,18 @@ final class SecurityEventStore { await refresh() } + /// Local-only triage state (spec §11) — no API write, no scope beyond + /// read needed. Removes the event from the active stream. + func markSeen(_ eventID: String) async { + var state = await persistenceStore.load() + state.seenEventIDs.insert(eventID) + await persistenceStore.save(state) + + rawEvents.removeAll { $0.id == eventID } + totalFetchedCount = rawEvents.count + applyMinimumSeverityFilter() + } + func removeRepo(_ repoFullName: String) async { var state = await persistenceStore.load() state.watchedRepos.removeAll { $0 == repoFullName } |
