1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-01 01:32:04 +03:00
vimr/VimR/PrefService.swift
2017-04-30 09:25:15 +02:00

30 lines
713 B
Swift

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
import Swifter
fileprivate let defaults = UserDefaults.standard
class PrefService {
typealias MainWindowPair = StateActionPair<AppState, UuidAction<MainWindow.Action>>
static let compatibleVersion = "168"
static let lastCompatibleVersion = "128"
func applyPref<ActionType>(_ pair: StateActionPair<AppState, ActionType>) {
defaults.setValue(pair.state.dict(), forKey: PrefService.compatibleVersion)
}
func applyMainWindow(_ pair: MainWindowPair) {
guard case .close = pair.action.payload else {
return
}
defaults.setValue(pair.state.dict(), forKey: PrefService.compatibleVersion)
}
}