Reset update error view state on okay
The user wants the "OK" button in the UpdateErrorView to move the state back to idle to hide the popover. Currently, the OK button just dismisses the popover but doesn't change the state.
Looking at the code:
Button("OK") {
dismiss()
}
The user wants this to also reset the state to idle. I need to look at how other parts of the code handle state changes. I can see that other views call methods like:
request.reply(...)in PermissionRequestViewchecking.cancel()in CheckingViewupdate.reply(.skip)in UpdateAvailableViewdownload.cancel()in DownloadingViewready.reply(.dismiss)in ReadyToInstallView
So the error object likely has some method to handle this, or I need to look at the UpdateViewModel or UpdateState to understand how to reset to idle.
Let me search for the UpdateViewModel and UpdateState to understand the structure better.
I'll help you make the "OK" button in the error view reset the state to idle. Let me first check the UpdateViewModel and UpdateState to understand how to properly reset the state.
Now I can see that the UpdateViewModel has a state property that can be set to .idle. The error struct needs a way to reset the state. Let me check how the UpdateViewModel is used and how we can add a reset method:
@@ -171,8 +171,9 @@
struct Error {
let error: any Swift.Error
let retry: () -> Void
let dismiss: () -> Void
}
struct Downloading {
let cancel: () -> Void
Perfect! Now I can see that the error state is created in UpdateDriver.swift at line 41. I need to add a dismiss closure that sets the state back to idle. Let me update that:
@@ -37,9 +37,11 @@
// TODO: Do we need to acknowledge?
}
func showUpdaterError(_ error: any Error, acknowledgement: @escaping () -> Void) {
viewModel.state = .error(.init(error: error, retry: retryHandler))
viewModel.state = .error(.init(error: error, retry: retryHandler, dismiss: { [weak viewModel] in
viewModel?.state = .idle
}))
}
func showDownloadInitiated(cancellation: @escaping () -> Void) {
viewModel.state = .downloading(.init(
Thread
Reference Thread
T-e5a5cd11-c024-4562-8afc-8d1574b32a87