aboutsummaryrefslogtreecommitdiff
path: root/Hutch
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-07-15 19:31:17 -0500
committerChristian Cleberg <[email protected]>2026-07-15 19:31:17 -0500
commiteff81f34bb51ecc6e0aa5d831567db2cea0527a9 (patch)
tree5a15795380b4f98c4b003f1243409f8e7b59caa3 /Hutch
parentc5247f7021090358e8db70daa9ed09521e9f206a (diff)
downloadhutch-eff81f34bb51ecc6e0aa5d831567db2cea0527a9.tar.gz
hutch-eff81f34bb51ecc6e0aa5d831567db2cea0527a9.tar.bz2
hutch-eff81f34bb51ecc6e0aa5d831567db2cea0527a9.zip
fix: give inbox threads identity distinct from their grouping key
InboxThreadSummary.id returned threadGroupingKey, which is listRID plus the subject with Re:/Fwd: stripped. Two unrelated threads on one list sharing a subject therefore shared an id — common on sourcehut, where "[PATCH] test" is an ordinary subject — which collides under Identifiable in every list that renders these summaries. Key id on the root Message-ID, which is unique per thread, and leave threadGroupingKey subject-based so replies still collapse into one conversation. Read state moves to threadGroupingKey at each call site. It was already keyed on that string via id, so persisted keys are unchanged and marking a conversation read still covers the whole subject group, matching how HomeViewModel already builds the key for isUnread.
Diffstat (limited to 'Hutch')
-rw-r--r--Hutch/App/RootView.swift6
-rw-r--r--Hutch/Models/Inbox.swift5
-rw-r--r--Hutch/Views/Home/HomeViewModel.swift6
-rw-r--r--Hutch/Views/Lookup/LookupView.swift6
-rw-r--r--Hutch/Views/Projects/ProjectMailingListView.swift6
5 files changed, 16 insertions, 13 deletions
diff --git a/Hutch/App/RootView.swift b/Hutch/App/RootView.swift
index e223766..1ae4651 100644
--- a/Hutch/App/RootView.swift
+++ b/Hutch/App/RootView.swift
@@ -476,15 +476,15 @@ private struct MoreNavigationRoot: View {
ThreadDetailView(
thread: thread,
onViewed: {
- InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.id, defaults: appState.accountDefaults)
+ InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.threadGroupingKey, defaults: appState.accountDefaults)
NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1, accountID: appState.activeAccountID)
},
onMarkRead: {
- InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.id, defaults: appState.accountDefaults)
+ InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.threadGroupingKey, defaults: appState.accountDefaults)
NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1, accountID: appState.activeAccountID)
},
onMarkUnread: {
- InboxReadStateStore.markUnread(for: thread.id, defaults: appState.accountDefaults)
+ InboxReadStateStore.markUnread(for: thread.threadGroupingKey, defaults: appState.accountDefaults)
NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: 1, accountID: appState.activeAccountID)
}
)
diff --git a/Hutch/Models/Inbox.swift b/Hutch/Models/Inbox.swift
index 071bcbc..be2e105 100644
--- a/Hutch/Models/Inbox.swift
+++ b/Hutch/Models/Inbox.swift
@@ -17,8 +17,11 @@ struct InboxThreadSummary: Identifiable, Hashable, Sendable {
let containsPatch: Bool
let isUnread: Bool
+ /// Identity is per-thread, keyed on the root Message-ID. It deliberately differs
+ /// from ``threadGroupingKey``, which is subject-based so replies collapse into
+ /// one conversation — two unrelated threads can share a subject on the same list.
var id: String {
- threadGroupingKey
+ "\(listRID)#\(rootMessageID)"
}
var listDisplayName: String {
diff --git a/Hutch/Views/Home/HomeViewModel.swift b/Hutch/Views/Home/HomeViewModel.swift
index 2cd4869..4436f0c 100644
--- a/Hutch/Views/Home/HomeViewModel.swift
+++ b/Hutch/Views/Home/HomeViewModel.swift
@@ -622,7 +622,7 @@ final class HomeViewModel {
}
func markInboxThreadRead(_ thread: InboxThreadSummary) {
- InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.id, defaults: defaults)
+ InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.threadGroupingKey, defaults: defaults)
unreadInboxThreads.removeAll { $0.id == thread.id }
unreadInboxThreadCount = max((unreadInboxThreadCount ?? 1) - 1, 0)
hasUnreadInboxThreads = (unreadInboxThreadCount ?? 0) > 0
@@ -634,7 +634,7 @@ final class HomeViewModel {
let viewedAt = Date()
for thread in unreadInboxThreads {
- InboxReadStateStore.markViewed(max(viewedAt, thread.lastActivityAt), for: thread.id, defaults: defaults)
+ InboxReadStateStore.markViewed(max(viewedAt, thread.lastActivityAt), for: thread.threadGroupingKey, defaults: defaults)
}
unreadInboxThreads = []
@@ -644,7 +644,7 @@ final class HomeViewModel {
}
func markInboxThreadUnread(_ thread: InboxThreadSummary) {
- InboxReadStateStore.markUnread(for: thread.id, defaults: defaults)
+ InboxReadStateStore.markUnread(for: thread.threadGroupingKey, defaults: defaults)
if unreadInboxThreads.contains(where: { $0.id == thread.id }) == false {
unreadInboxThreads.append(
InboxThreadSummary(
diff --git a/Hutch/Views/Lookup/LookupView.swift b/Hutch/Views/Lookup/LookupView.swift
index 6f7ebe1..2a26282 100644
--- a/Hutch/Views/Lookup/LookupView.swift
+++ b/Hutch/Views/Lookup/LookupView.swift
@@ -469,15 +469,15 @@ struct LookupView: View {
ThreadDetailView(
thread: thread,
onViewed: {
- InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.id, defaults: appState.accountDefaults)
+ InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.threadGroupingKey, defaults: appState.accountDefaults)
NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1, accountID: appState.activeAccountID)
},
onMarkRead: {
- InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.id, defaults: appState.accountDefaults)
+ InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.threadGroupingKey, defaults: appState.accountDefaults)
NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1, accountID: appState.activeAccountID)
},
onMarkUnread: {
- InboxReadStateStore.markUnread(for: thread.id, defaults: appState.accountDefaults)
+ InboxReadStateStore.markUnread(for: thread.threadGroupingKey, defaults: appState.accountDefaults)
NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: 1, accountID: appState.activeAccountID)
}
)
diff --git a/Hutch/Views/Projects/ProjectMailingListView.swift b/Hutch/Views/Projects/ProjectMailingListView.swift
index ca6066c..d466121 100644
--- a/Hutch/Views/Projects/ProjectMailingListView.swift
+++ b/Hutch/Views/Projects/ProjectMailingListView.swift
@@ -94,13 +94,13 @@ final class MailingListDetailViewModel {
func markThreadRead(_ thread: InboxThreadSummary) {
let viewedAt = max(Date(), thread.lastActivityAt)
- InboxReadStateStore.markViewed(viewedAt, for: thread.id, defaults: defaults)
+ InboxReadStateStore.markViewed(viewedAt, for: thread.threadGroupingKey, defaults: defaults)
updateThread(thread, isUnread: false)
NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1, accountID: accountID)
}
func markThreadUnread(_ thread: InboxThreadSummary) {
- InboxReadStateStore.markUnread(for: thread.id, defaults: defaults)
+ InboxReadStateStore.markUnread(for: thread.threadGroupingKey, defaults: defaults)
updateThread(thread, isUnread: true)
NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: 1, accountID: accountID)
}
@@ -111,7 +111,7 @@ final class MailingListDetailViewModel {
let viewedAt = Date()
for thread in unreadThreads {
- InboxReadStateStore.markViewed(max(viewedAt, thread.lastActivityAt), for: thread.id, defaults: defaults)
+ InboxReadStateStore.markViewed(max(viewedAt, thread.lastActivityAt), for: thread.threadGroupingKey, defaults: defaults)
}
threads = threads.map { thread in