diff options
| author | Christian Cleberg <[email protected]> | 2026-03-22 20:42:45 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-03-22 20:42:45 -0500 |
| commit | 1f8b7a23529462c3c332753d33810b5c9f692bbc (patch) | |
| tree | 17526dae77a7579b270e6b9cca6224c9020f772d /Hutch/Views/Inbox | |
| parent | e03791d6c15ee0caac033d1b1b390c5d65a69d57 (diff) | |
| download | hutch-1f8b7a23529462c3c332753d33810b5c9f692bbc.tar.gz hutch-1f8b7a23529462c3c332753d33810b5c9f692bbc.tar.bz2 hutch-1f8b7a23529462c3c332753d33810b5c9f692bbc.zip | |
feat: add search to builds, trackers, tickets, pastes, mailing lists, and inbox
Diffstat (limited to 'Hutch/Views/Inbox')
| -rw-r--r-- | Hutch/Views/Inbox/InboxView.swift | 9 | ||||
| -rw-r--r-- | Hutch/Views/Inbox/InboxViewModel.swift | 11 |
2 files changed, 19 insertions, 1 deletions
diff --git a/Hutch/Views/Inbox/InboxView.swift b/Hutch/Views/Inbox/InboxView.swift index 74f78d5..5724964 100644 --- a/Hutch/Views/Inbox/InboxView.swift +++ b/Hutch/Views/Inbox/InboxView.swift @@ -30,7 +30,7 @@ struct InboxView: View { @Bindable var vm = viewModel List { - ForEach(viewModel.threads) { thread in + ForEach(viewModel.filteredThreads) { thread in Button { selectThread(thread) } label: { @@ -45,6 +45,11 @@ struct InboxView: View { } } } + .searchable( + text: $vm.searchText, + placement: .navigationBarDrawer(displayMode: .always), + prompt: "Search inbox" + ) .listStyle(.plain) .overlay { if viewModel.isLoading, viewModel.threads.isEmpty { @@ -55,6 +60,8 @@ struct InboxView: View { message: error, retryAction: { await viewModel.loadThreads() } ) + } else if !viewModel.threads.isEmpty, viewModel.filteredThreads.isEmpty { + ContentUnavailableView.search(text: viewModel.searchText) } else if viewModel.threads.isEmpty, viewModel.error == nil { ContentUnavailableView( "Inbox Zero", diff --git a/Hutch/Views/Inbox/InboxViewModel.swift b/Hutch/Views/Inbox/InboxViewModel.swift index 00d47b5..42ce223 100644 --- a/Hutch/Views/Inbox/InboxViewModel.swift +++ b/Hutch/Views/Inbox/InboxViewModel.swift @@ -62,6 +62,7 @@ final class InboxViewModel { private(set) var threads: [InboxThreadSummary] = [] private(set) var isLoading = false var error: String? + var searchText = "" private let client: SRHTClient private let listThreadFetchLimit = 10 @@ -164,6 +165,16 @@ final class InboxViewModel { threads.first(where: { $0.id == id }) } + var filteredThreads: [InboxThreadSummary] { + let q = searchText.trimmingCharacters(in: .whitespacesAndNewlines).lowercased() + guard !q.isEmpty else { return threads } + return threads.filter { + $0.displaySubject.lowercased().contains(q) || + $0.listName.lowercased().contains(q) || + $0.latestSender.canonicalName.lowercased().contains(q) + } + } + private func fetchSubscriptions() async throws -> [InboxActivitySubscription] { var subscriptions: [InboxActivitySubscription] = [] var cursor: String? |
