Prefix store keys with "Passepartout." domain
Also remove stale preferences from early betas after migrating relevant ones. Extend KeyValueStore with removeValue() for this purpose.
This commit is contained in:
parent
02a9db057f
commit
85129f17af
|
@ -32,6 +32,6 @@ enum AppPreference: String, KeyStoreDomainLocation {
|
|||
case didHandleSubreddit
|
||||
|
||||
var domain: String {
|
||||
"App"
|
||||
"Passepartout.App"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ private extension PersistenceManager {
|
|||
case persistenceAuthor
|
||||
|
||||
var domain: String {
|
||||
"PersistenceManager"
|
||||
"Passepartout.PersistenceManager"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,9 +35,37 @@ private typealias Map = [String: Any]
|
|||
// MARK: Migrate old store
|
||||
|
||||
extension UpgradeManager {
|
||||
fileprivate enum LegacyStoreKey: String, KeyStoreLocation {
|
||||
fileprivate enum LegacyStoreKey: String, KeyStoreLocation, CaseIterable {
|
||||
case activeProfileId
|
||||
|
||||
case launchesOnLogin
|
||||
|
||||
case isStatusMenuEnabled
|
||||
|
||||
case isShowingFavorites
|
||||
|
||||
case confirmsQuit
|
||||
|
||||
case logFormat
|
||||
|
||||
case tunnelLogFormat
|
||||
|
||||
case masksPrivateData
|
||||
|
||||
case didHandleSubreddit
|
||||
|
||||
case persistenceAuthor
|
||||
|
||||
case didMigrateToV2
|
||||
|
||||
case other1 = "MasksPrivateData"
|
||||
|
||||
case other2 = "DidHandleSubreddit"
|
||||
|
||||
case other3 = "Convenience.Reviewer.LastVersion"
|
||||
|
||||
case other4 = "didMigrateKeychainContext"
|
||||
|
||||
var key: String {
|
||||
rawValue
|
||||
}
|
||||
|
@ -50,6 +78,10 @@ extension UpgradeManager {
|
|||
}
|
||||
didMigrateToV2 = legacyDidMigrateToV2
|
||||
}
|
||||
|
||||
LegacyStoreKey.allCases.forEach {
|
||||
store.removeValue(forLocation: $0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ private extension UpgradeManager {
|
|||
case didMigrateToV2
|
||||
|
||||
var domain: String {
|
||||
"UpgradeManager"
|
||||
"Passepartout.UpgradeManager"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -298,7 +298,7 @@ private extension VPNManager {
|
|||
case masksPrivateData
|
||||
|
||||
var domain: String {
|
||||
"VPNManager"
|
||||
"Passepartout.VPNManager"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -484,7 +484,7 @@ private extension ProfileManager {
|
|||
case activeProfileId
|
||||
|
||||
var domain: String {
|
||||
"ProfileManager"
|
||||
"Passepartout.ProfileManager"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,4 +43,6 @@ public protocol KeyValueStore {
|
|||
func setValue<L: KeyStoreLocation, V>(_ value: V, forLocation location: L)
|
||||
|
||||
func value<L: KeyStoreLocation, V>(forLocation location: L) -> V?
|
||||
|
||||
func removeValue<L: KeyStoreLocation>(forLocation location: L)
|
||||
}
|
|
@ -39,4 +39,8 @@ public struct UserDefaultsStore: KeyValueStore {
|
|||
public func value<L: KeyStoreLocation, V>(forLocation location: L) -> V? {
|
||||
defaults.value(forKey: location.key) as? V
|
||||
}
|
||||
|
||||
public func removeValue<L: KeyStoreLocation>(forLocation location: L) {
|
||||
defaults.removeObject(forKey: location.key)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue