28 lines
994 B
Swift
28 lines
994 B
Swift
import Sparkle
|
|
import Cocoa
|
|
|
|
extension UpdateDriver: SPUUpdaterDelegate {
|
|
func feedURLString(for updater: SPUUpdater) -> String? {
|
|
Bundle.main.object(forInfoDictionaryKey: "SUFeedURL") as? String
|
|
}
|
|
|
|
/// Called when an update is scheduled to install silently,
|
|
/// which occurs when automatic download is enabled.
|
|
func updater(_ updater: SPUUpdater, willInstallUpdateOnQuit item: SUAppcastItem, immediateInstallationBlock immediateInstallHandler: @escaping () -> Void) -> Bool {
|
|
viewModel.state = .installing(.init(
|
|
isAutoUpdate: true,
|
|
retryTerminatingApplication: immediateInstallHandler,
|
|
dismiss: { [weak viewModel] in
|
|
viewModel?.state = .idle
|
|
}
|
|
))
|
|
return true
|
|
}
|
|
|
|
func updaterWillRelaunchApplication(_ updater: SPUUpdater) {
|
|
NSApp.invalidateRestorableState()
|
|
for window in NSApp.windows {
|
|
window.invalidateRestorableState()
|
|
}
|
|
}
|
|
}
|