diff options
| author | Christian Cleberg <[email protected]> | 2026-04-12 18:59:34 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-12 18:59:34 -0500 |
| commit | b3d3e68e742650cb8a448a1f51fea7fb7783c36f (patch) | |
| tree | 3508d8e3dcd31568fca293de9655a7f5957d40ea /Hutch/Views/Builds/BuildListView.swift | |
| parent | b526cddd8ec421eba00feecbdffae3978cb61b34 (diff) | |
| download | hutch-b3d3e68e742650cb8a448a1f51fea7fb7783c36f.tar.gz hutch-b3d3e68e742650cb8a448a1f51fea7fb7783c36f.tar.bz2 hutch-b3d3e68e742650cb8a448a1f51fea7fb7783c36f.zip | |
feat: add builds auto-refresh and repo filtering
implements: https://todo.sr.ht/~ccleberg/hutch/17
implements: https://todo.sr.ht/~ccleberg/hutch/18
Diffstat (limited to 'Hutch/Views/Builds/BuildListView.swift')
| -rw-r--r-- | Hutch/Views/Builds/BuildListView.swift | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/Hutch/Views/Builds/BuildListView.swift b/Hutch/Views/Builds/BuildListView.swift index 705f97c..b53d64b 100644 --- a/Hutch/Views/Builds/BuildListView.swift +++ b/Hutch/Views/Builds/BuildListView.swift @@ -2,11 +2,17 @@ import SwiftUI struct BuildListView: View { @AppStorage(AppStorageKeys.swipeActionsEnabled) private var swipeActionsEnabled = true + @AppStorage(AppStorageKeys.buildsAutoRefreshInterval) private var autoRefreshRawValue = 0 + @AppStorage(AppStorageKeys.buildsRepoFilter) private var savedRepoFilter = "" @Environment(AppState.self) private var appState @State private var viewModel: BuildListViewModel? @State private var showSubmitSheet = false @State private var submittedJobId: Int? + private var autoRefreshInterval: AutoRefreshInterval { + AutoRefreshInterval(rawValue: autoRefreshRawValue) ?? .off + } + var body: some View { Group { if let viewModel { @@ -17,7 +23,52 @@ struct BuildListView: View { } .navigationTitle("Builds") .toolbar { - if viewModel != nil { + if let viewModel { + ToolbarItem(placement: .topBarLeading) { + Menu { + Section("Auto-Refresh") { + ForEach(AutoRefreshInterval.allCases, id: \.self) { interval in + Button { + autoRefreshRawValue = interval.rawValue + viewModel.startAutoRefresh(interval: interval) + } label: { + if interval.rawValue == autoRefreshRawValue { + Label(interval.label, systemImage: "checkmark") + } else { + Text(interval.label) + } + } + } + } + Section("Filter by Tag") { + Button { + savedRepoFilter = "" + viewModel.repoFilter = "" + } label: { + if savedRepoFilter.isEmpty { + Label("All", systemImage: "checkmark") + } else { + Text("All") + } + } + ForEach(viewModel.availableTags, id: \.self) { tag in + Button { + savedRepoFilter = tag + viewModel.repoFilter = tag + } label: { + if savedRepoFilter == tag { + Label(tag, systemImage: "checkmark") + } else { + Text(tag) + } + } + } + } + } label: { + Image(systemName: "line.3.horizontal.decrease.circle") + } + .accessibilityLabel("Build filters") + } ToolbarItem(placement: .topBarTrailing) { Button { showSubmitSheet = true @@ -54,10 +105,15 @@ struct BuildListView: View { .task { if viewModel == nil { let vm = BuildListViewModel(client: appState.client) + vm.repoFilter = savedRepoFilter viewModel = vm await vm.loadJobs() + vm.startAutoRefresh(interval: autoRefreshInterval) } } + .onDisappear { + viewModel?.stopAutoRefresh() + } } @ViewBuilder |
