mirror of https://github.com/oxen-io/session-ios
commit
bd7c62beb8
@ -1 +1 @@
|
||||
Subproject commit 3fbdfaf0158f182482961b8b989e27abef36fea1
|
||||
Subproject commit 67dbced37481e0011a3df1397ed57711384a4957
|
@ -0,0 +1,53 @@
|
||||
import Foundation
|
||||
|
||||
public enum LKUserDefaults {
|
||||
|
||||
public enum Bool : Swift.String {
|
||||
case hasLaunchedOnce
|
||||
case hasSeenOpenGroupSuggestionSheet
|
||||
case hasViewedSeed
|
||||
/// Whether the device was unlinked as a slave device (used to notify the user on the landing screen).
|
||||
case wasUnlinked
|
||||
}
|
||||
|
||||
public enum Double : Swift.String {
|
||||
case lastDeviceTokenUpload = "lastDeviceTokenUploadTime"
|
||||
}
|
||||
|
||||
public enum String {
|
||||
case slaveDeviceName(Swift.String)
|
||||
case deviceToken
|
||||
/// `nil` if this is a master device or if the user hasn't linked a device.
|
||||
case masterHexEncodedPublicKey
|
||||
|
||||
public var key: Swift.String {
|
||||
switch self {
|
||||
case .slaveDeviceName(let hexEncodedPublicKey): return "\(hexEncodedPublicKey)_display_name"
|
||||
case .deviceToken: return "deviceToken"
|
||||
case .masterHexEncodedPublicKey: return "masterDeviceHexEncodedPublicKey"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public extension UserDefaults {
|
||||
|
||||
public subscript(bool: LKUserDefaults.Bool) -> Bool {
|
||||
get { return self.bool(forKey: bool.rawValue) }
|
||||
set { set(newValue, forKey: bool.rawValue) }
|
||||
}
|
||||
|
||||
public subscript(double: LKUserDefaults.Double) -> Double {
|
||||
get { return self.double(forKey: double.rawValue) }
|
||||
set { set(newValue, forKey: double.rawValue) }
|
||||
}
|
||||
|
||||
public subscript(string: LKUserDefaults.String) -> String? {
|
||||
get { return self.string(forKey: string.key) }
|
||||
set { set(newValue, forKey: string.key) }
|
||||
}
|
||||
|
||||
public var isMasterDevice: Bool {
|
||||
return (self[.masterHexEncodedPublicKey] == nil)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue