4 struct UpdateCommands: Commands {
5 let updaterController: SPUStandardUpdaterController
7 var body: some Commands {
8 CommandGroup(after: .appInfo) {
9 CheckForUpdatesView(updater: updaterController.updater)
15 struct CheckForUpdatesView: View {
16 @ObservedObject private var checkForUpdatesViewModel: CheckForUpdatesViewModel
17 private let updater: SPUUpdater
19 init(updater: SPUUpdater) {
20 self.updater = updater
22 // Create our view model for our CheckForUpdatesView
23 self.checkForUpdatesViewModel = CheckForUpdatesViewModel(updater: updater)
27 Button("Check for Updates…", action: updater.checkForUpdates)
28 .disabled(!checkForUpdatesViewModel.canCheckForUpdates)
32 final class CheckForUpdatesViewModel: ObservableObject {
33 @Published var canCheckForUpdates = false
35 init(updater: SPUUpdater) {
36 updater.publisher(for: \.canCheckForUpdates)
37 .assign(to: &$canCheckForUpdates)