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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 2 deletions

View File

@ -88,7 +88,7 @@ final class BugReportScreenCoordinator: CoordinatorProtocol {
private func startLoading(label: String = L10n.commonLoading, progressPublisher: CurrentValuePublisher<Double, Never>) {
parameters.userIndicatorController?.submitIndicator(
UserIndicator(id: Self.loadingIndicatorIdentifier,
type: .modal(progress: .published(progressPublisher), interactiveDismissDisabled: false, allowsInteraction: false),
type: .modal(progress: .published(progressPublisher), interactiveDismissDisabled: false, allowsInteraction: true),
title: label,
persistent: true)
)

View File

@ -28,6 +28,7 @@ struct BugReportScreenViewState: BindableState {
var screenshot: UIImage?
var bindings: BugReportScreenViewStateBindings
let isModallyPresented: Bool
var shouldDisableInteraction = false
}
struct BugReportScreenViewStateBindings {

View File

@ -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):

View File

@ -32,6 +32,7 @@ struct BugReportScreen: View {
sendLogsSection
canContactSection
}
.disabled(context.viewState.shouldDisableInteraction)
.scrollDismissesKeyboard(.immediately)
.compoundList()
.navigationTitle(L10n.commonReportABug)
@ -131,6 +132,7 @@ struct BugReportScreen: View {
context.send(viewAction: .submit)
}
.disabled(context.reportText.count < 5)
.disabled(context.viewState.shouldDisableInteraction)
}
}
}

0
changelog.d/1198.bugfix Normal file
View File