diff options
Diffstat (limited to 'Hutch/Views/Inbox/InboxViewModel.swift')
| -rw-r--r-- | Hutch/Views/Inbox/InboxViewModel.swift | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Hutch/Views/Inbox/InboxViewModel.swift b/Hutch/Views/Inbox/InboxViewModel.swift index 1d4cfd3..edb7593 100644 --- a/Hutch/Views/Inbox/InboxViewModel.swift +++ b/Hutch/Views/Inbox/InboxViewModel.swift @@ -150,6 +150,18 @@ final class InboxViewModel { NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1) } + func markAllThreadsRead() { + guard !threads.isEmpty else { return } + + let viewedAt = Date() + for thread in threads where thread.isUnread { + InboxReadStateStore.markViewed(max(viewedAt, thread.lastActivityAt), for: thread.id) + } + + threads.removeAll { $0.isUnread } + NeedsAttentionSnapshotStore.update(unreadInboxThreads: threads.count) + } + func markThreadUnread(_ thread: InboxThreadSummary) { InboxReadStateStore.markUnread(for: thread.id) updateThread(thread, isUnread: true) @@ -178,6 +190,10 @@ final class InboxViewModel { } } + var hasUnreadThreads: Bool { + threads.contains(where: \.isUnread) + } + private func fetchSubscriptions() async throws -> [InboxActivitySubscription] { var subscriptions: [InboxActivitySubscription] = [] var cursor: String? |
