2017-02-28 00:45:26 +03:00
|
|
|
/**
|
|
|
|
* Tae Won Ha - http://taewon.de - @hataewon
|
|
|
|
* See LICENSE
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
2017-04-30 10:25:15 +03:00
|
|
|
class GeneralPrefReducer {
|
2017-02-28 00:45:26 +03:00
|
|
|
|
|
|
|
typealias Pair = StateActionPair<AppState, GeneralPref.Action>
|
|
|
|
|
2017-04-30 10:25:15 +03:00
|
|
|
func reduce(_ pair: Pair) -> Pair {
|
|
|
|
var state = pair.state
|
2017-02-28 00:45:26 +03:00
|
|
|
|
2017-04-30 10:25:15 +03:00
|
|
|
switch pair.action {
|
2017-02-28 00:45:26 +03:00
|
|
|
|
2017-04-30 10:25:15 +03:00
|
|
|
case let .setOpenOnLaunch(value):
|
|
|
|
state.openNewMainWindowOnLaunch = value
|
2017-02-28 00:45:26 +03:00
|
|
|
|
2017-06-13 23:36:43 +03:00
|
|
|
case let .setAfterLastWindowAction(action):
|
|
|
|
state.afterLastWindowAction = action
|
|
|
|
|
2017-04-30 10:25:15 +03:00
|
|
|
case let .setOpenOnReactivation(value):
|
|
|
|
state.openNewMainWindowOnReactivation = value
|
2017-02-28 00:45:26 +03:00
|
|
|
|
2017-04-30 10:25:15 +03:00
|
|
|
case let .setIgnorePatterns(patterns):
|
|
|
|
state.openQuickly.ignorePatterns = patterns
|
|
|
|
state.openQuickly.ignoreToken = Token()
|
2017-02-28 00:45:26 +03:00
|
|
|
|
|
|
|
}
|
2017-04-30 10:25:15 +03:00
|
|
|
|
|
|
|
return StateActionPair(state: state, action: pair.action)
|
2017-02-28 00:45:26 +03:00
|
|
|
}
|
|
|
|
}
|