1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-24 03:25:03 +03:00
vimr/VimR/FileBrowserReducer.swift

35 lines
741 B
Swift
Raw Normal View History

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):
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
case .refresh:
2017-05-14 13:06:21 +03:00
state.lastFileSystemUpdate = Marked(state.cwd)
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
}
}