macos: "Check for updates" cancels whatever the current update state is (#9203)
This mainly allows users who have a pending update but didn't install it for some time to re-check to see if there is something newer in the mean time.pull/9208/head
parent
9f726492ac
commit
3d837cbbce
|
|
@ -93,7 +93,22 @@ class UpdateController {
|
||||||
///
|
///
|
||||||
/// This is typically connected to a menu item action.
|
/// This is typically connected to a menu item action.
|
||||||
@objc func checkForUpdates() {
|
@objc func checkForUpdates() {
|
||||||
updater.checkForUpdates()
|
// If we're already idle, then just check for updates immediately.
|
||||||
|
if viewModel.state == .idle {
|
||||||
|
updater.checkForUpdates()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we're not idle then we need to cancel any prior state.
|
||||||
|
installCancellable?.cancel()
|
||||||
|
viewModel.state.cancel()
|
||||||
|
|
||||||
|
// The above will take time to settle, so we delay the check for some time.
|
||||||
|
// The 100ms is arbitrary and I'd rather not, but we have to wait more than
|
||||||
|
// one loop tick it seems.
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) { [weak self] in
|
||||||
|
self?.updater.checkForUpdates()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validate the check for updates menu item.
|
/// Validate the check for updates menu item.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue