Commit 325f398a24
325f398a24e44998695ee8b30c6fd089eaac9b9a
parent: 9e886c16d7
Verified · cmc ci/accessibility: success ci/sync-man-pages: success
cmc <hello@cleberg.net> · 2026-10-23 06:43 UTC
ThreadDetailView: markRead/markUnread init and standalone for deep links
Layout: unified · split
Hutch/App/RootView.swift
+1 −15
| @@ -477,21 +477,7 @@ private struct MoreNavigationRoot: View { |
| 477 | case .mailingList(let mailingList): |
477 | case .mailingList(let mailingList): |
| 478 | MailingListDetailView(mailingList: mailingList) |
478 | MailingListDetailView(mailingList: mailingList) |
| 479 | case .thread(let thread): |
479 | case .thread(let thread): |
| 480 | ThreadDetailView( |
480 | ThreadDetailView.standalone(thread, appState: appState) |
| 481 | thread: thread, |
| |
| 482 | onViewed: { |
| |
| 483 | InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.threadGroupingKey, defaults: appState.accountDefaults) |
| |
| 484 | NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1, accountID: appState.activeAccountID) |
| |
| 485 | }, |
| |
| 486 | onMarkRead: { |
| |
| 487 | InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.threadGroupingKey, defaults: appState.accountDefaults) |
| |
| 488 | NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1, accountID: appState.activeAccountID) |
| |
| 489 | }, |
| |
| 490 | onMarkUnread: { |
| |
| 491 | InboxReadStateStore.markUnread(for: thread.threadGroupingKey, defaults: appState.accountDefaults) |
| |
| 492 | NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: 1, accountID: appState.activeAccountID) |
| |
| 493 | } |
| |
| 494 | ) |
| |
| 495 | case .manPageBrowser: |
481 | case .manPageBrowser: |
| 496 | ManPageBrowserView() |
482 | ManPageBrowserView() |
| 497 | case .manPage(let url): |
483 | case .manPage(let url): |
Hutch/Views/Inbox/ThreadDetailView.swift
+21
| @@ -34,6 +34,27 @@ struct ThreadDetailView: View { |
| 34 | self._isUnread = State(initialValue: thread.isUnread) |
34 | self._isUnread = State(initialValue: thread.isUnread) |
| 35 | } |
35 | } |
| 36 | |
36 | |
| |
37 | /// Viewing the thread and Mark as Read both run `markRead`. |
| |
38 | init(thread: InboxThreadSummary, markRead: @escaping () -> Void, markUnread: @escaping () -> Void) { |
| |
39 | self.init(thread: thread, onViewed: markRead, onMarkRead: markRead, onMarkUnread: markUnread) |
| |
40 | } |
| |
41 | |
| |
42 | /// A thread opened on its own, not from a list: its read state lives in the account's defaults |
| |
43 | /// and the needs-attention count. |
| |
44 | static func standalone(_ thread: InboxThreadSummary, appState: AppState) -> ThreadDetailView { |
| |
45 | ThreadDetailView( |
| |
46 | thread: thread, |
| |
47 | markRead: { |
| |
48 | InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.threadGroupingKey, defaults: appState.accountDefaults) |
| |
49 | NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1, accountID: appState.activeAccountID) |
| |
50 | }, |
| |
51 | markUnread: { |
| |
52 | InboxReadStateStore.markUnread(for: thread.threadGroupingKey, defaults: appState.accountDefaults) |
| |
53 | NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: 1, accountID: appState.activeAccountID) |
| |
54 | } |
| |
55 | ) |
| |
56 | } |
| |
57 | |
| 37 | var body: some View { |
58 | var body: some View { |
| 38 | ModelContent(model: viewModel, loadingMessage: "Loading thread…") { content($0) } |
59 | ModelContent(model: viewModel, loadingMessage: "Loading thread…") { content($0) } |
| 39 | .navigationTitle("Thread") |
60 | .navigationTitle("Thread") |
Hutch/Views/Lookup/LookupView.swift
+1 −15
| @@ -467,21 +467,7 @@ struct LookupView: View { |
| 467 | case .mailingList(let mailingList): |
467 | case .mailingList(let mailingList): |
| 468 | MailingListDetailView(mailingList: mailingList) |
468 | MailingListDetailView(mailingList: mailingList) |
| 469 | case .thread(let thread): |
469 | case .thread(let thread): |
| 470 | ThreadDetailView( |
470 | ThreadDetailView.standalone(thread, appState: appState) |
| 471 | thread: thread, |
| |
| 472 | onViewed: { |
| |
| 473 | InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.threadGroupingKey, defaults: appState.accountDefaults) |
| |
| 474 | NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1, accountID: appState.activeAccountID) |
| |
| 475 | }, |
| |
| 476 | onMarkRead: { |
| |
| 477 | InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.threadGroupingKey, defaults: appState.accountDefaults) |
| |
| 478 | NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1, accountID: appState.activeAccountID) |
| |
| 479 | }, |
| |
| 480 | onMarkUnread: { |
| |
| 481 | InboxReadStateStore.markUnread(for: thread.threadGroupingKey, defaults: appState.accountDefaults) |
| |
| 482 | NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: 1, accountID: appState.activeAccountID) |
| |
| 483 | } |
| |
| 484 | ) |
| |
| 485 | case .manPageBrowser: |
471 | case .manPageBrowser: |
| 486 | ManPageBrowserView() |
472 | ManPageBrowserView() |
| 487 | case .manPage(let url): |
473 | case .manPage(let url): |
Hutch/Views/Projects/ProjectMailingListView.swift
+2 −9
| @@ -564,15 +564,8 @@ struct MailingListDetailView: View { |
| 564 | NavigationLink { |
564 | NavigationLink { |
| 565 | ThreadDetailView( |
565 | ThreadDetailView( |
| 566 | thread: thread, |
566 | thread: thread, |
| 567 | onViewed: { |
567 | markRead: { viewModel.markThreadRead(thread) }, |
| 568 | viewModel.markThreadRead(thread) |
568 | markUnread: { viewModel.markThreadUnread(thread) } |
| 569 | }, |
| |
| 570 | onMarkRead: { |
| |
| 571 | viewModel.markThreadRead(thread) |
| |
| 572 | }, |
| |
| 573 | onMarkUnread: { |
| |
| 574 | viewModel.markThreadUnread(thread) |
| |
| 575 | } |
| |
| 576 | ) |
569 | ) |
| 577 | } label: { |
570 | } label: { |
| 578 | InboxThreadRow(thread: thread) |
571 | InboxThreadRow(thread: thread) |
Hutch/Views/Work/WorkView.swift
+2 −3
| @@ -134,9 +134,8 @@ struct WorkView: View { |
| 134 | NavigationLink { |
134 | NavigationLink { |
| 135 | ThreadDetailView( |
135 | ThreadDetailView( |
| 136 | thread: thread, |
136 | thread: thread, |
| 137 | onViewed: { viewModel.markInboxThreadRead(thread) }, |
137 | markRead: { viewModel.markInboxThreadRead(thread) }, |
| 138 | onMarkRead: { viewModel.markInboxThreadRead(thread) }, |
138 | markUnread: { viewModel.markInboxThreadUnread(thread) } |
| 139 | onMarkUnread: { viewModel.markInboxThreadUnread(thread) } |
| |
| 140 | ) |
139 | ) |
| 141 | } label: { |
140 | } label: { |
| 142 | WorkThreadRow(thread: thread) |
141 | WorkThreadRow(thread: thread) |