2 Copyright (C) 2024 Rubén Beltrán del Río
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see https://map.tranquil.systems.
20 struct UpdateCommands: Commands {
21 let updaterController: SPUStandardUpdaterController
23 var body: some Commands {
24 CommandGroup(after: .appInfo) {
25 CheckForUpdatesView(updater: updaterController.updater)
31 struct CheckForUpdatesView: View {
32 @ObservedObject private var checkForUpdatesViewModel: CheckForUpdatesViewModel
33 private let updater: SPUUpdater
35 init(updater: SPUUpdater) {
36 self.updater = updater
38 // Create our view model for our CheckForUpdatesView
39 self.checkForUpdatesViewModel = CheckForUpdatesViewModel(updater: updater)
43 Button("Check for Updates…", action: updater.checkForUpdates)
44 .disabled(!checkForUpdatesViewModel.canCheckForUpdates)
48 final class CheckForUpdatesViewModel: ObservableObject {
49 @Published var canCheckForUpdates = false
51 init(updater: SPUUpdater) {
52 updater.publisher(for: \.canCheckForUpdates)
53 .assign(to: &$canCheckForUpdates)