1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-29 16:56:40 +03:00
vimr/VimR/PrefService.swift
Tae Won Ha b1a6f7d5af
GH-325 Store the frame of the last window and cascase manually
- Rough draft: multiple screens are not handled yet.
2017-08-15 17:53:38 +02:00

34 lines
879 B
Swift

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
fileprivate let defaults = UserDefaults.standard
class PrefService {
typealias MainWindowPair = StateActionPair<AppState, UuidAction<MainWindow.Action>>
static let compatibleVersion = "168"
static let lastCompatibleVersion = "128"
// The following should only be used when Cmd-Q'ing
func applyPref(from appState: AppState) {
defaults.setValue(appState.dict(), forKey: PrefService.compatibleVersion)
}
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)
}
}