settings: record bool option keys

so that NostrScripts know which bool settings can be set
This commit is contained in:
William Casarin
2023-07-03 16:06:27 -07:00
parent 94bd194287
commit a6cbf50def

View File

@@ -15,6 +15,9 @@ let fallback_zap_amount = 1000
private var value: T
init(key: String, default_value: T) {
if T is bool {
UserSettingsStore.bool_options.insert(key)
}
self.key = pk_setting_key(UserSettingsStore.pubkey ?? "", key: key)
if let loaded = UserDefaults.standard.object(forKey: self.key) as? T {
self.value = loaded
@@ -77,6 +80,7 @@ let fallback_zap_amount = 1000
class UserSettingsStore: ObservableObject {
static var pubkey: String? = nil
static var shared: UserSettingsStore? = nil
static var bool_options = Set<String>()
@StringSetting(key: "default_wallet", default_value: .system_default_wallet)
var default_wallet: Wallet