1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-26 07:13:24 +03:00
vimr/VimR/FileBrowserReducer.swift

35 lines
741 B
Swift

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
class FileBrowserReducer {
typealias Pair = StateActionPair<UuidState<MainWindow.State>, FileBrowser.Action>
func reduce(_ pair: Pair) -> Pair {
var state = pair.state.payload
switch pair.action {
case let .open(url, mode):
state.urlsToOpen[url] = mode
state.viewToBeFocused = .neoVimView
case let .setAsWorkingDirectory(url):
state.cwdToSet = url
case let .setShowHidden(show):
state.fileBrowserShowHidden = show
case .refresh:
state.lastFileSystemUpdate = Marked(state.cwd)
}
return StateActionPair(state: UuidState(uuid: state.uuid, state: state), action: pair.action)
}
}