Fixe #1198 - Allow cancelling feeback submissions while they're uploading (#1692)

This commit is contained in:
Stefan Ceriu
2023-09-13 12:08:39 +03:00
committed by GitHub
parent f3618cda9d
commit add148b77d
5 changed files with 8 additions and 2 deletions
@@ -24,6 +24,7 @@ class BugReportScreenViewModel: BugReportScreenViewModelType, BugReportScreenVie
private let userID: String
private let deviceID: String?
private let actionsSubject: PassthroughSubject<BugReportScreenViewModelAction, Never> = .init()
@CancellableTask private var uploadTask: Task<Void, Never>?
var actions: AnyPublisher<BugReportScreenViewModelAction, Never> {
actionsSubject.eraseToAnyPublisher()
@@ -49,9 +50,11 @@ class BugReportScreenViewModel: BugReportScreenViewModelType, BugReportScreenVie
override func process(viewAction: BugReportScreenViewAction) {
switch viewAction {
case .cancel:
uploadTask = nil
actionsSubject.send(.cancel)
case .submit:
Task { await submitBugReport() }
state.shouldDisableInteraction = true
uploadTask = Task { await submitBugReport() }
case .removeScreenshot:
state.screenshot = nil
case let .attachScreenshot(image):