2024-06-19 15:15:27 +00:00
|
|
|
import Foundation
|
|
|
|
|
|
|
|
// Wrapper
|
|
|
|
@propertyWrapper
|
|
|
|
struct Storage<T> {
|
|
|
|
private let key: String
|
|
|
|
private let defaultValue: T
|
|
|
|
|
|
|
|
init(key: String, defaultValue: T) {
|
|
|
|
self.key = key
|
|
|
|
self.defaultValue = defaultValue
|
|
|
|
}
|
|
|
|
|
|
|
|
var wrappedValue: T {
|
|
|
|
get {
|
|
|
|
// Read value from UserDefaults
|
|
|
|
UserDefaults.standard.object(forKey: key) as? T ?? defaultValue
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
// Set value to UserDefaults
|
|
|
|
UserDefaults.standard.set(newValue, forKey: key)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Storage
|
2024-09-16 15:58:28 +00:00
|
|
|
private let kOmemoDeviceId = "conversations.classic.user.defaults.omemoDeviceId"
|
2024-06-19 15:15:27 +00:00
|
|
|
|
|
|
|
enum UserSettings {
|
2024-09-16 15:58:28 +00:00
|
|
|
@Storage(key: kOmemoDeviceId, defaultValue: 0)
|
|
|
|
static var omemoDeviceId: UInt32
|
2024-06-19 15:15:27 +00:00
|
|
|
}
|