diff options
| author | Christian Cleberg <[email protected]> | 2026-04-01 12:15:23 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-01 12:15:23 -0500 |
| commit | 109b0ea7e859de2d8b5a4dc22bf0472fd3b08eaa (patch) | |
| tree | ceb604cbf07102b3b386a60fd48a9dc2576e3684 /Hutch/Views/Inbox/InboxViewModel.swift | |
| parent | 367a9d8e9592d0c604356e74edea97e0791b32cd (diff) | |
| download | hutch-109b0ea7e859de2d8b5a4dc22bf0472fd3b08eaa.tar.gz hutch-109b0ea7e859de2d8b5a4dc22bf0472fd3b08eaa.tar.bz2 hutch-109b0ea7e859de2d8b5a4dc22bf0472fd3b08eaa.zip | |
fix: fixed inbox's inconsistent UX and adds a Mark All Read button
Fixes: https://todo.sr.ht/~ccleberg/Hutch/10
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? |
