1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-29 16:56:40 +03:00
vimr/VimR/FileBrowserReducer.swift
2017-05-14 12:06:21 +02:00

35 lines
736 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.cwd = 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)
}
}