From 109b0ea7e859de2d8b5a4dc22bf0472fd3b08eaa Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Wed, 1 Apr 2026 12:15:23 -0500 Subject: fix: fixed inbox's inconsistent UX and adds a Mark All Read button Fixes: https://todo.sr.ht/~ccleberg/Hutch/10 --- Hutch/Views/Inbox/InboxViewModel.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Hutch/Views/Inbox/InboxViewModel.swift') 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? -- cgit v1.2.3