You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
940 B

import Foundation
import Sparkle
/// Selbstaktualisierung über Sparkle. Mawari sucht einmal am Tag von selbst
/// (SUEnableAutomaticChecks in project.yml) und bietet gefundene Updates an;
/// installiert wird erst nach Zustimmung. Appcast: update.zielke.studio/mawari.
@MainActor
final class UpdateController: ObservableObject {
private let controller: SPUStandardUpdaterController
@Published private(set) var canCheck = true
private var observation: NSKeyValueObservation?
init() {
controller = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)
observation = controller.updater.observe(\.canCheckForUpdates, options: [.initial, .new]) { [weak self] updater, _ in
let can = updater.canCheckForUpdates
Task { @MainActor in self?.canCheck = can }
}
}
func checkForUpdates() { controller.updater.checkForUpdates() }
}

Powered by TurnKey Linux.