diff options
| author | Christian Cleberg <[email protected]> | 2026-07-15 23:27:03 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-07-15 23:27:03 -0500 |
| commit | 0ad430c79eedac4140680e3aaca238969ac711b1 (patch) | |
| tree | e4928ae266acb2282a12e8212b82635890f50089 /Hutch/Views/Projects/ProjectMailingListView.swift | |
| parent | 922502a2c74c66034f3ec2db6612f2a36d242042 (diff) | |
| parent | 97e8b49fcb56751fa0e80a332484db8252753417 (diff) | |
| download | hutch-0ad430c79eedac4140680e3aaca238969ac711b1.tar.gz hutch-0ad430c79eedac4140680e3aaca238969ac711b1.tar.bz2 hutch-0ad430c79eedac4140680e3aaca238969ac711b1.zip | |
Merge pull request #5 from zerolabsco/inbox-unread-baseline
Start a new account at zero unread
Diffstat (limited to 'Hutch/Views/Projects/ProjectMailingListView.swift')
| -rw-r--r-- | Hutch/Views/Projects/ProjectMailingListView.swift | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/Hutch/Views/Projects/ProjectMailingListView.swift b/Hutch/Views/Projects/ProjectMailingListView.swift index 696cf6b..10bb19e 100644 --- a/Hutch/Views/Projects/ProjectMailingListView.swift +++ b/Hutch/Views/Projects/ProjectMailingListView.swift @@ -104,8 +104,14 @@ final class MailingListDetailViewModel { responseType: ProjectMailingListThreadsResponse.self ) + let activity = await MailingListActivityLoader.load( + client: client, + listRID: mailingList.rid, + since: InboxReadStateStore.baseline(defaults: defaults) ?? .distantPast + ) + threads = deduplicateThreads( - response.list.threads.results.map(makeSummary(from:)) + response.list.threads.results.map { makeSummary(from: $0, activity: activity) } ) patchsets = Self.patchsets(from: response.list.threads.results) } catch { @@ -193,7 +199,10 @@ final class MailingListDetailViewModel { NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -unreadThreads.count, accountID: accountID) } - private func makeSummary(from thread: ProjectMailingListThreadPayload) -> InboxThreadSummary { + private func makeSummary( + from thread: ProjectMailingListThreadPayload, + activity: MailingListActivity + ) -> InboxThreadSummary { let normalizedSubject = thread.subject .replacingOccurrences(of: #"\s+"#, with: " ", options: .regularExpression) .trimmingCharacters(in: .whitespacesAndNewlines) @@ -201,6 +210,10 @@ final class MailingListDetailViewModel { .lowercased() let threadID = "\(mailingList.rid)#\(normalizedSubject)" + // thread.updated is the root email's insert time and never advances when a + // reply lands, so activity has to come from the list's mail feed. + let lastActivityAt = activity.lastActivity(rootEmailID: thread.root.id, fallback: thread.updated) + return InboxThreadSummary( rootEmailID: thread.root.id, rootMessageID: thread.root.messageID, @@ -212,11 +225,11 @@ final class MailingListDetailViewModel { listOwner: mailingList.owner, subject: thread.subject, latestSender: thread.sender, - lastActivityAt: thread.updated, + lastActivityAt: lastActivityAt, messageCount: thread.replies + 1, repo: nil, containsPatch: thread.root.patch != nil || thread.subject.localizedCaseInsensitiveContains("[patch"), - isUnread: InboxReadStateStore.isUnread(threadID: threadID, lastActivityAt: thread.updated, defaults: defaults) + isUnread: InboxReadStateStore.isUnread(threadID: threadID, lastActivityAt: lastActivityAt, defaults: defaults) ) } |
