From 82e54ad018ae5fa5cdf90c0d763e09e99bc0e933 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Sun, 22 Mar 2026 20:42:53 -0500 Subject: feat: swipe actions on tickets, pastes, builds, and home dashboard --- Hutch/Views/Builds/BuildListViewModel.swift | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'Hutch/Views/Builds/BuildListViewModel.swift') 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 + } } -- cgit v1.2.3