summaryrefslogtreecommitdiff
path: root/Hutch/Views/Inbox/InboxViewModel.swift
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-03-19 15:17:38 -0500
committerChristian Cleberg <[email protected]>2026-03-19 15:17:38 -0500
commit6ba4e967d5dfb5d3c7bb97a0f2662f3180595563 (patch)
tree572bef546fcca19ad37bc1aa7cfb153eb2bf8eb7 /Hutch/Views/Inbox/InboxViewModel.swift
parent1e3c748119c6e9eec27f02146f17ea0302ff648a (diff)
downloadhutch-6ba4e967d5dfb5d3c7bb97a0f2662f3180595563.tar.gz
hutch-6ba4e967d5dfb5d3c7bb97a0f2662f3180595563.tar.bz2
hutch-6ba4e967d5dfb5d3c7bb97a0f2662f3180595563.zip
feat: implement support for projects, lists, and pastes
Diffstat (limited to 'Hutch/Views/Inbox/InboxViewModel.swift')
-rw-r--r--Hutch/Views/Inbox/InboxViewModel.swift10
1 files changed, 8 insertions, 2 deletions
diff --git a/Hutch/Views/Inbox/InboxViewModel.swift b/Hutch/Views/Inbox/InboxViewModel.swift
index 9211b40..9c1ef45 100644
--- a/Hutch/Views/Inbox/InboxViewModel.swift
+++ b/Hutch/Views/Inbox/InboxViewModel.swift
@@ -127,7 +127,9 @@ final class InboxViewModel {
let subscriptions = try await fetchSubscriptions()
let mailingLists = deduplicateMailingLists(subscriptions.compactMap(\.list))
let fetchedThreads = try await fetchThreads(for: mailingLists)
- threads = fetchedThreads.sorted { lhs, rhs in
+ threads = fetchedThreads
+ .filter(\.isUnread)
+ .sorted { lhs, rhs in
if lhs.lastActivityAt == rhs.lastActivityAt {
return lhs.subject.localizedCaseInsensitiveCompare(rhs.subject) == .orderedAscending
}
@@ -145,7 +147,7 @@ final class InboxViewModel {
inboxListLogger.debug(
"Inbox mark read: key=\(thread.id, privacy: .public) latestActivityAt=\(thread.lastActivityAt.ISO8601Format(), privacy: .public) storedLastViewedAt=\(viewedAt.ISO8601Format(), privacy: .public)"
)
- updateThread(thread, isUnread: false)
+ threads.removeAll { $0.id == thread.id }
}
func markThreadUnread(_ thread: InboxThreadSummary) {
@@ -329,6 +331,10 @@ final class InboxViewModel {
private func updateThread(_ thread: InboxThreadSummary, isUnread: Bool) {
guard let index = threads.firstIndex(where: { $0.id == thread.id }) else { return }
let current = threads[index]
+ if !isUnread {
+ threads.remove(at: index)
+ return
+ }
threads[index] = InboxThreadSummary(
rootEmailID: current.rootEmailID,
rootMessageID: current.rootMessageID,