macos: make auto-update optional

When unset, we use Sparkle's default behavior, which is based on the
user's preference stored in the standard user defaults.

The rest of the previous behavior is preserved:
- When SUEnableAutomaticChecks is explicitly false, auto-updates are
  disabled.
- When 'auto-update' is set, use its value to set Sparkle's auto-update
  behavior.
This commit is contained in:
Jon Parise
2025-01-02 15:47:56 -05:00
parent b68e9a10e0
commit 713dd24ab9
3 changed files with 16 additions and 15 deletions

View File

@@ -437,15 +437,14 @@ extension Ghostty {
return v;
}
var autoUpdate: AutoUpdate {
let defaultValue = AutoUpdate.check
guard let config = self.config else { return defaultValue }
var autoUpdate: AutoUpdate? {
guard let config = self.config else { return nil }
var v: UnsafePointer<Int8>? = nil
let key = "auto-update"
guard ghostty_config_get(config, &v, key, UInt(key.count)) else { return defaultValue }
guard let ptr = v else { return defaultValue }
guard ghostty_config_get(config, &v, key, UInt(key.count)) else { return nil }
guard let ptr = v else { return nil }
let str = String(cString: ptr)
return AutoUpdate(rawValue: str) ?? defaultValue
return AutoUpdate(rawValue: str)
}
var autoUpdateChannel: AutoUpdateChannel {