Merge pull request #254 from vaygr/opt-out-updates
Add a setting to disable auto update checks
This commit is contained in:
commit
76dc612064
@ -14,6 +14,7 @@ struct SettingsView: View {
|
|||||||
@ObservedObject private var mediaController = MediaController.shared
|
@ObservedObject private var mediaController = MediaController.shared
|
||||||
@ObservedObject private var playbackController = PlaybackController.shared
|
@ObservedObject private var playbackController = PlaybackController.shared
|
||||||
@AppStorage("hasCompletedOnboarding") private var hasCompletedOnboarding = true
|
@AppStorage("hasCompletedOnboarding") private var hasCompletedOnboarding = true
|
||||||
|
@AppStorage("autoUpdateCheck") private var autoUpdateCheck = true
|
||||||
@State private var showResetOnboardingAlert = false
|
@State private var showResetOnboardingAlert = false
|
||||||
@State private var currentShortcut = KeyboardShortcuts.getShortcut(for: .toggleMiniRecorder)
|
@State private var currentShortcut = KeyboardShortcuts.getShortcut(for: .toggleMiniRecorder)
|
||||||
@State private var isCustomCancelEnabled = false
|
@State private var isCustomCancelEnabled = false
|
||||||
@ -228,9 +229,15 @@ struct SettingsView: View {
|
|||||||
subtitle: "Keep VoiceInk up to date"
|
subtitle: "Keep VoiceInk up to date"
|
||||||
) {
|
) {
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
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()
|
.settingsDescription()
|
||||||
|
|
||||||
|
Toggle("Enable automatic update checks", isOn: $autoUpdateCheck)
|
||||||
|
.toggleStyle(.switch)
|
||||||
|
.onChange(of: autoUpdateCheck) { _, newValue in
|
||||||
|
updaterViewModel.toggleAutoUpdates(newValue)
|
||||||
|
}
|
||||||
|
|
||||||
Button("Check for Updates Now") {
|
Button("Check for Updates Now") {
|
||||||
updaterViewModel.checkForUpdates()
|
updaterViewModel.checkForUpdates()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -172,6 +172,8 @@ struct VoiceInkApp: App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class UpdaterViewModel: ObservableObject {
|
class UpdaterViewModel: ObservableObject {
|
||||||
|
@AppStorage("autoUpdateCheck") private var autoUpdateCheck = true
|
||||||
|
|
||||||
private let updaterController: SPUStandardUpdaterController
|
private let updaterController: SPUStandardUpdaterController
|
||||||
|
|
||||||
@Published var canCheckForUpdates = false
|
@Published var canCheckForUpdates = false
|
||||||
@ -180,13 +182,17 @@ class UpdaterViewModel: ObservableObject {
|
|||||||
updaterController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)
|
updaterController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)
|
||||||
|
|
||||||
// Enable automatic update checking
|
// Enable automatic update checking
|
||||||
updaterController.updater.automaticallyChecksForUpdates = true
|
updaterController.updater.automaticallyChecksForUpdates = autoUpdateCheck
|
||||||
updaterController.updater.updateCheckInterval = 24 * 60 * 60
|
updaterController.updater.updateCheckInterval = 24 * 60 * 60
|
||||||
|
|
||||||
updaterController.updater.publisher(for: \.canCheckForUpdates)
|
updaterController.updater.publisher(for: \.canCheckForUpdates)
|
||||||
.assign(to: &$canCheckForUpdates)
|
.assign(to: &$canCheckForUpdates)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func toggleAutoUpdates(_ value: Bool) {
|
||||||
|
updaterController.updater.automaticallyChecksForUpdates = value
|
||||||
|
}
|
||||||
|
|
||||||
func checkForUpdates() {
|
func checkForUpdates() {
|
||||||
// This is for manual checks - will show UI
|
// This is for manual checks - will show UI
|
||||||
updaterController.checkForUpdates(nil)
|
updaterController.checkForUpdates(nil)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user