2017-02-24 02:24:30 +03:00
|
|
|
/**
|
|
|
|
* Tae Won Ha - http://taewon.de - @hataewon
|
|
|
|
* See LICENSE
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
2017-04-30 10:25:15 +03:00
|
|
|
class FileBrowserReducer {
|
2017-02-24 02:24:30 +03:00
|
|
|
|
2017-02-24 12:51:24 +03:00
|
|
|
typealias Pair = StateActionPair<UuidState<MainWindow.State>, FileBrowser.Action>
|
2017-02-24 02:24:30 +03:00
|
|
|
|
2017-04-30 10:25:15 +03:00
|
|
|
func reduce(_ pair: Pair) -> Pair {
|
|
|
|
var state = pair.state.payload
|
2017-02-24 02:24:30 +03:00
|
|
|
|
2017-04-30 10:25:15 +03:00
|
|
|
switch pair.action {
|
2017-02-24 02:24:30 +03:00
|
|
|
|
2017-04-30 10:25:15 +03:00
|
|
|
case let .open(url, mode):
|
|
|
|
state.urlsToOpen[url] = mode
|
|
|
|
state.viewToBeFocused = .neoVimView
|
2017-02-24 02:24:30 +03:00
|
|
|
|
2017-04-30 10:25:15 +03:00
|
|
|
case let .setAsWorkingDirectory(url):
|
2017-06-10 00:16:06 +03:00
|
|
|
state.cwdToSet = url
|
2017-02-24 02:24:30 +03:00
|
|
|
|
2017-04-30 10:25:15 +03:00
|
|
|
case let .setShowHidden(show):
|
|
|
|
state.fileBrowserShowHidden = show
|
2017-02-26 12:55:07 +03:00
|
|
|
|
2017-05-12 00:33:59 +03:00
|
|
|
case .refresh:
|
2017-05-14 13:06:21 +03:00
|
|
|
state.lastFileSystemUpdate = Marked(state.cwd)
|
2017-05-12 00:33:59 +03:00
|
|
|
|
2017-02-24 02:24:30 +03:00
|
|
|
}
|
2017-04-30 10:25:15 +03:00
|
|
|
|
|
|
|
return StateActionPair(state: UuidState(uuid: state.uuid, state: state), action: pair.action)
|
2017-02-24 02:24:30 +03:00
|
|
|
}
|
|
|
|
}
|