summaryrefslogtreecommitdiff
path: root/Hutch/Views/Builds/BuildListViewModel.swift
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-03-22 20:42:53 -0500
committerChristian Cleberg <[email protected]>2026-03-22 20:42:53 -0500
commit82e54ad018ae5fa5cdf90c0d763e09e99bc0e933 (patch)
treecafdbc8f4116af5cc6e0ca706e05ced599e26570 /Hutch/Views/Builds/BuildListViewModel.swift
parent1f8b7a23529462c3c332753d33810b5c9f692bbc (diff)
downloadhutch-82e54ad018ae5fa5cdf90c0d763e09e99bc0e933.tar.gz
hutch-82e54ad018ae5fa5cdf90c0d763e09e99bc0e933.tar.bz2
hutch-82e54ad018ae5fa5cdf90c0d763e09e99bc0e933.zip
feat: swipe actions on tickets, pastes, builds, and home dashboard
Diffstat (limited to 'Hutch/Views/Builds/BuildListViewModel.swift')
-rw-r--r--Hutch/Views/Builds/BuildListViewModel.swift37
1 files changed, 37 insertions, 0 deletions
diff --git a/Hutch/Views/Builds/BuildListViewModel.swift b/Hutch/Views/Builds/BuildListViewModel.swift
index 7b0b0b9..0757ad8 100644
--- a/Hutch/Views/Builds/BuildListViewModel.swift
+++ b/Hutch/Views/Builds/BuildListViewModel.swift
@@ -194,6 +194,35 @@ final class BuildListViewModel {
}
}
+ func cancelJob(_ job: JobSummary) async {
+ guard job.status.isCancellable else { return }
+
+ do {
+ _ = try await client.execute(
+ service: .builds,
+ query: Self.cancelMutation,
+ variables: ["id": job.id],
+ responseType: CancelResponse.self
+ )
+ if let index = jobs.firstIndex(where: { $0.id == job.id }) {
+ let updated = JobSummary(
+ id: job.id,
+ created: job.created,
+ updated: job.updated,
+ status: .cancelled,
+ note: job.note,
+ tags: job.tags,
+ visibility: job.visibility,
+ image: job.image,
+ tasks: job.tasks
+ )
+ jobs[index] = updated
+ }
+ } catch {
+ self.error = error.userFacingMessage
+ }
+ }
+
// MARK: - Private
private func fetchPage(cursor: String?, useCache: Bool) async throws -> JobsPage {
@@ -235,4 +264,12 @@ final class BuildListViewModel {
hasMore = page.cursor != nil
}
}
+
+ private struct CancelResponse: Decodable, Sendable {
+ struct CancelResult: Decodable, Sendable {
+ let id: Int
+ }
+
+ let cancel: CancelResult
+ }
}