1
1
mirror of https://github.com/qvacua/vimr.git synced 2025-01-01 18:23:48 +03:00
vimr/VimR/PrefService.swift

34 lines
879 B
Swift
Raw Normal View History

2017-02-28 20:53:49 +03:00
/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
fileprivate let defaults = UserDefaults.standard
class PrefService {
2017-02-28 20:53:49 +03:00
2017-04-30 10:25:15 +03:00
typealias MainWindowPair = StateActionPair<AppState, UuidAction<MainWindow.Action>>
2017-03-29 22:36:12 +03:00
static let compatibleVersion = "168"
2017-03-11 19:00:55 +03:00
static let lastCompatibleVersion = "128"
2017-03-01 18:59:23 +03:00
// The following should only be used when Cmd-Q'ing
func applyPref(from appState: AppState) {
defaults.setValue(appState.dict(), forKey: PrefService.compatibleVersion)
}
2017-04-30 10:25:15 +03:00
func applyPref<ActionType>(_ pair: StateActionPair<AppState, ActionType>) {
defaults.setValue(pair.state.dict(), forKey: PrefService.compatibleVersion)
}
2017-04-30 10:25:15 +03:00
func applyMainWindow(_ pair: MainWindowPair) {
guard case .close = pair.action.payload else {
return
}
2017-04-30 10:25:15 +03:00
defaults.setValue(pair.state.dict(), forKey: PrefService.compatibleVersion)
2017-02-28 20:53:49 +03:00
}
2017-04-30 10:25:15 +03:00
}