diff options
| author | Christian Cleberg <[email protected]> | 2026-04-12 23:19:20 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-12 23:19:20 -0500 |
| commit | ee9f2904aa319231b7047fca3cb069f0c07019cd (patch) | |
| tree | 69a18234512c63f38f0d477e0023969698ec3c9e /Hutch/Views/Projects | |
| parent | 72f860e0e171f6aac4e7d896e7a571147dbcb5c5 (diff) | |
| download | hutch-ee9f2904aa319231b7047fca3cb069f0c07019cd.tar.gz hutch-ee9f2904aa319231b7047fca3cb069f0c07019cd.tar.bz2 hutch-ee9f2904aa319231b7047fca3cb069f0c07019cd.zip | |
feat: add multi-account support
Implements: https://todo.sr.ht/~ccleberg/hutch/49
Implements: https://todo.sr.ht/~ccleberg/hutch/50
Implements: https://todo.sr.ht/~ccleberg/hutch/51
Diffstat (limited to 'Hutch/Views/Projects')
| -rw-r--r-- | Hutch/Views/Projects/ProjectDetailView.swift | 4 | ||||
| -rw-r--r-- | Hutch/Views/Projects/ProjectMailingListView.swift | 35 |
2 files changed, 24 insertions, 15 deletions
diff --git a/Hutch/Views/Projects/ProjectDetailView.swift b/Hutch/Views/Projects/ProjectDetailView.swift index 11758ae..dc8b24d 100644 --- a/Hutch/Views/Projects/ProjectDetailView.swift +++ b/Hutch/Views/Projects/ProjectDetailView.swift @@ -22,7 +22,7 @@ struct ProjectDetailView: View { private var isPinnedToHome: Bool { _ = pinChangeCount guard let currentUserKey else { return false } - return ProjectPinStore.isPinned(projectID: displayedProject.id, for: currentUserKey) + return ProjectPinStore.isPinned(projectID: displayedProject.id, for: currentUserKey, defaults: appState.accountDefaults) } var body: some View { @@ -243,7 +243,7 @@ struct ProjectDetailView: View { private func togglePinnedState() { guard let currentUserKey else { return } - ProjectPinStore.togglePin(projectID: displayedProject.id, for: currentUserKey) + ProjectPinStore.togglePin(projectID: displayedProject.id, for: currentUserKey, defaults: appState.accountDefaults) pinChangeCount += 1 } diff --git a/Hutch/Views/Projects/ProjectMailingListView.swift b/Hutch/Views/Projects/ProjectMailingListView.swift index 832c889..478e471 100644 --- a/Hutch/Views/Projects/ProjectMailingListView.swift +++ b/Hutch/Views/Projects/ProjectMailingListView.swift @@ -36,6 +36,8 @@ final class MailingListDetailViewModel { private let mailingList: InboxMailingListReference private let client: SRHTClient + private let defaults: UserDefaults + private let accountID: String private static let listThreadsQuery = """ query projectMailingListThreads($rid: ID!) { @@ -57,9 +59,11 @@ final class MailingListDetailViewModel { } """ - init(mailingList: InboxMailingListReference, client: SRHTClient) { + init(mailingList: InboxMailingListReference, client: SRHTClient, defaults: UserDefaults, accountID: String) { self.mailingList = mailingList self.client = client + self.defaults = defaults + self.accountID = accountID } var filteredThreads: [InboxThreadSummary] { @@ -90,15 +94,15 @@ final class MailingListDetailViewModel { func markThreadRead(_ thread: InboxThreadSummary) { let viewedAt = max(Date(), thread.lastActivityAt) - InboxReadStateStore.markViewed(viewedAt, for: thread.id) + InboxReadStateStore.markViewed(viewedAt, for: thread.id, defaults: defaults) updateThread(thread, isUnread: false) - NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1) + NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1, accountID: accountID) } func markThreadUnread(_ thread: InboxThreadSummary) { - InboxReadStateStore.markUnread(for: thread.id) + InboxReadStateStore.markUnread(for: thread.id, defaults: defaults) updateThread(thread, isUnread: true) - NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: 1) + NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: 1, accountID: accountID) } private func makeSummary(from thread: ProjectMailingListThreadPayload) -> InboxThreadSummary { @@ -124,7 +128,7 @@ final class MailingListDetailViewModel { messageCount: thread.replies + 1, repo: nil, containsPatch: thread.root.patch != nil || thread.subject.localizedCaseInsensitiveContains("[patch"), - isUnread: InboxReadStateStore.isUnread(threadID: threadID, lastActivityAt: thread.updated) + isUnread: InboxReadStateStore.isUnread(threadID: threadID, lastActivityAt: thread.updated, defaults: defaults) ) } @@ -238,7 +242,12 @@ struct MailingListDetailView: View { .navigationBarTitleDisplayMode(.inline) .task { if viewModel == nil { - let viewModel = MailingListDetailViewModel(mailingList: mailingList, client: appState.client) + let viewModel = MailingListDetailViewModel( + mailingList: mailingList, + client: appState.client, + defaults: appState.accountDefaults, + accountID: appState.activeAccountID + ) self.viewModel = viewModel await viewModel.loadThreads() } @@ -261,16 +270,16 @@ struct MailingListDetailView: View { ThreadDetailView( thread: thread, onViewed: { - InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.id) - NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1) + InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.id, defaults: appState.accountDefaults) + NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1, accountID: appState.activeAccountID) }, onMarkRead: { - InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.id) - NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1) + InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.id, defaults: appState.accountDefaults) + NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1, accountID: appState.activeAccountID) }, onMarkUnread: { - InboxReadStateStore.markUnread(for: thread.id) - NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: 1) + InboxReadStateStore.markUnread(for: thread.id, defaults: appState.accountDefaults) + NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: 1, accountID: appState.activeAccountID) } ) } label: { |
