Browse Source

Update DataStore.swift

pull/113/head
Abhishek 3 years ago
parent
commit
86d957c29b
  1. 27
      Clocker/Overall App/DataStore.swift

27
Clocker/Overall App/DataStore.swift

@ -27,6 +27,11 @@ class DataStore: NSObject {
// Since these pref can accessed every second, let's cache this // Since these pref can accessed every second, let's cache this
private var shouldDisplayDayInMenubar: Bool = false private var shouldDisplayDayInMenubar: Bool = false
private var shouldDisplayDateInMenubar: Bool = false private var shouldDisplayDateInMenubar: Bool = false
private static let timeFormatsWithSuffix: Set<NSNumber> = Set([NSNumber(integerLiteral: 0),
NSNumber(integerLiteral: 3),
NSNumber(integerLiteral: 4),
NSNumber(integerLiteral: 6),
NSNumber(integerLiteral: 7)])
class func shared() -> DataStore { class func shared() -> DataStore {
return sharedStore return sharedStore
@ -101,23 +106,10 @@ class DataStore: NSObject {
userDefaults.set(currentLineup, forKey: CLDefaultPreferenceKey) userDefaults.set(currentLineup, forKey: CLDefaultPreferenceKey)
} }
private func shouldDisplayHelper(_ key: String) -> Bool {
guard let value = retrieve(key: key) as? NSNumber else {
return false
}
return value.isEqual(to: NSNumber(value: 0))
}
func timezoneFormat() -> NSNumber { func timezoneFormat() -> NSNumber {
return userDefaults.object(forKey: CLSelectedTimeZoneFormatKey) as? NSNumber ?? NSNumber(integerLiteral: 0) return userDefaults.object(forKey: CLSelectedTimeZoneFormatKey) as? NSNumber ?? NSNumber(integerLiteral: 0)
} }
static let timeFormatsWithSuffix: Set<NSNumber> = Set([NSNumber(integerLiteral: 0),
NSNumber(integerLiteral: 3),
NSNumber(integerLiteral: 4),
NSNumber(integerLiteral: 6),
NSNumber(integerLiteral: 7)])
func isBufferRequiredForTwelveHourFormats() -> Bool { func isBufferRequiredForTwelveHourFormats() -> Bool {
return DataStore.timeFormatsWithSuffix.contains(timezoneFormat()) return DataStore.timeFormatsWithSuffix.contains(timezoneFormat())
} }
@ -165,4 +157,13 @@ class DataStore: NSObject {
return value == 0 return value == 0
} }
} }
//MARK: Private
private func shouldDisplayHelper(_ key: String) -> Bool {
guard let value = retrieve(key: key) as? NSNumber else {
return false
}
return value.isEqual(to: NSNumber(value: 0))
}
} }

Loading…
Cancel
Save