1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-24 03:25:03 +03:00
vimr/VimR/FileMonitorReducer.swift
2017-05-14 12:06:21 +02:00

34 lines
788 B
Swift

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
class FileMonitorReducer {
typealias Pair = StateActionPair<AppState, FileMonitor.Action>
func reduce(_ pair: Pair) -> Pair {
var state = pair.state
switch pair.action {
case let .change(in: url):
if let fileItem = FileItemUtils.item(for: url, root: state.openQuickly.root, create: false) {
fileItem.needsScanChildren = true
}
state.mainWindows
.filter { (uuid, mainWindow) in url == mainWindow.cwd || url.isContained(in: mainWindow.cwd) }
.map { $0.0 }
.forEach { uuid in
state.mainWindows[uuid]?.lastFileSystemUpdate = Marked(url)
}
}
return StateActionPair(state: state, action: pair.action)
}
}