macos: fix driver for retry to trigger update check again

This commit is contained in:
Mitchell Hashimoto
2025-10-09 08:51:26 -07:00
parent a2fbaec613
commit bbf875216f

View File

@@ -10,7 +10,8 @@ class UpdateDriver: NSObject, SPUUserDriver {
super.init() super.init()
} }
func show(_ request: SPUUpdatePermissionRequest, reply: @escaping @Sendable (SUUpdatePermissionResponse) -> Void) { func show(_ request: SPUUpdatePermissionRequest,
reply: @escaping @Sendable (SUUpdatePermissionResponse) -> Void) {
viewModel.state = .permissionRequest(.init(request: request, reply: reply)) viewModel.state = .permissionRequest(.init(request: request, reply: reply))
} }
@@ -18,7 +19,9 @@ class UpdateDriver: NSObject, SPUUserDriver {
viewModel.state = .checking(.init(cancel: cancellation)) viewModel.state = .checking(.init(cancel: cancellation))
} }
func showUpdateFound(with appcastItem: SUAppcastItem, state: SPUUserUpdateState, reply: @escaping @Sendable (SPUUserUpdateChoice) -> Void) { func showUpdateFound(with appcastItem: SUAppcastItem,
state: SPUUserUpdateState,
reply: @escaping @Sendable (SPUUserUpdateChoice) -> Void) {
viewModel.state = .updateAvailable(.init(appcastItem: appcastItem, reply: reply)) viewModel.state = .updateAvailable(.init(appcastItem: appcastItem, reply: reply))
} }
@@ -31,20 +34,22 @@ class UpdateDriver: NSObject, SPUUserDriver {
// We don't do anything with release notes. See `showUpdateReleaseNotes` // We don't do anything with release notes. See `showUpdateReleaseNotes`
} }
func showUpdateNotFoundWithError(_ error: any Error, acknowledgement: @escaping () -> Void) { func showUpdateNotFoundWithError(_ error: any Error,
acknowledgement: @escaping () -> Void) {
viewModel.state = .notFound viewModel.state = .notFound
// TODO: Do we need to acknowledge? acknowledgement()
} }
func showUpdaterError(_ error: any Error, acknowledgement: @escaping () -> Void) { func showUpdaterError(_ error: any Error,
acknowledgement: @escaping () -> Void) {
viewModel.state = .error(.init( viewModel.state = .error(.init(
error: error, error: error,
retry: { retry: { [weak viewModel] in
guard let delegate = NSApp.delegate as? AppDelegate else { viewModel?.state = .idle
return DispatchQueue.main.async {
guard let delegate = NSApp.delegate as? AppDelegate else { return }
delegate.checkForUpdates(self)
} }
// TODO fill this in
}, },
dismiss: { [weak viewModel] in dismiss: { [weak viewModel] in
viewModel?.state = .idle viewModel?.state = .idle