From bbf929e36e351de36971e9205f277354c2c97f63 Mon Sep 17 00:00:00 2001 From: Val V Date: Tue, 26 Aug 2025 01:01:18 +0000 Subject: [PATCH] Add a setting to disable auto update checks --- VoiceInk/Views/Settings/SettingsView.swift | 9 ++++++++- VoiceInk/VoiceInk.swift | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/VoiceInk/Views/Settings/SettingsView.swift b/VoiceInk/Views/Settings/SettingsView.swift index 74dd7cb..7c11c57 100644 --- a/VoiceInk/Views/Settings/SettingsView.swift +++ b/VoiceInk/Views/Settings/SettingsView.swift @@ -14,6 +14,7 @@ struct SettingsView: View { @ObservedObject private var mediaController = MediaController.shared @ObservedObject private var playbackController = PlaybackController.shared @AppStorage("hasCompletedOnboarding") private var hasCompletedOnboarding = true + @AppStorage("autoUpdateCheck") private var autoUpdateCheck = true @State private var showResetOnboardingAlert = false @State private var currentShortcut = KeyboardShortcuts.getShortcut(for: .toggleMiniRecorder) @State private var isCustomCancelEnabled = false @@ -228,9 +229,15 @@ struct SettingsView: View { subtitle: "Keep VoiceInk up to date" ) { VStack(alignment: .leading, spacing: 8) { - Text("VoiceInk automatically checks for updates on launch and every other day.") + Text("Choose whether VoiceInk should automatically check for updates on launch and every other day.") .settingsDescription() + Toggle("Enable automatic update checks", isOn: $autoUpdateCheck) + .toggleStyle(.switch) + .onChange(of: autoUpdateCheck) { _, newValue in + updaterViewModel.toggleAutoUpdates(newValue) + } + Button("Check for Updates Now") { updaterViewModel.checkForUpdates() } diff --git a/VoiceInk/VoiceInk.swift b/VoiceInk/VoiceInk.swift index 28a3c97..11a0027 100644 --- a/VoiceInk/VoiceInk.swift +++ b/VoiceInk/VoiceInk.swift @@ -172,6 +172,8 @@ struct VoiceInkApp: App { } class UpdaterViewModel: ObservableObject { + @AppStorage("autoUpdateCheck") private var autoUpdateCheck = true + private let updaterController: SPUStandardUpdaterController @Published var canCheckForUpdates = false @@ -180,13 +182,17 @@ class UpdaterViewModel: ObservableObject { updaterController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil) // Enable automatic update checking - updaterController.updater.automaticallyChecksForUpdates = true + updaterController.updater.automaticallyChecksForUpdates = autoUpdateCheck updaterController.updater.updateCheckInterval = 24 * 60 * 60 updaterController.updater.publisher(for: \.canCheckForUpdates) .assign(to: &$canCheckForUpdates) } + func toggleAutoUpdates(_ value: Bool) { + updaterController.updater.automaticallyChecksForUpdates = value + } + func checkForUpdates() { // This is for manual checks - will show UI updaterController.checkForUpdates(nil)