From 9ea8b7614a1ca96712c87327e90790bdd22a7b62 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Wed, 20 Feb 2019 17:21:37 +0800 Subject: [PATCH] refactor: give up on optional argument arrays --- src/driver/core/FileExplorer.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/driver/core/FileExplorer.ts b/src/driver/core/FileExplorer.ts index 06a5adf..13de683 100644 --- a/src/driver/core/FileExplorer.ts +++ b/src/driver/core/FileExplorer.ts @@ -118,10 +118,10 @@ const handleKeyDown: MethodCreator< function handleVerticalMove(index: number) { if (0 <= index && index < nodes.length) { DOMHelper.focusFileExplorer() - dispatch.call(focusNode, nodes[index]) + dispatch.call(focusNode, nodes[index], false) } else { DOMHelper.focusSearchInput() - dispatch.call(focusNode, null) + dispatch.call(focusNode, null, false) } } @@ -149,7 +149,7 @@ const handleKeyDown: MethodCreator< // go forward to the start of the list, find the closest node with lower depth const parentNode = getVisibleParentNode(nodes, focusedNode, depths) if (parentNode) { - dispatch.call(focusNode, parentNode) + dispatch.call(focusNode, parentNode, false) } } break @@ -161,7 +161,7 @@ const handleKeyDown: MethodCreator< if (expandedNodes.has(focusedNode)) { const nextNode = nodes[focusedNodeIndex + 1] if (depths.get(nextNode) > depths.get(focusedNode)) { - dispatch.call(focusNode, nextNode) + dispatch.call(focusNode, nextNode, false) } } else { dispatch.call(setExpand, focusedNode, true) @@ -194,11 +194,11 @@ const handleKeyDown: MethodCreator< switch (key) { case 'ArrowDown': DOMHelper.focusFileExplorer() - dispatch.call(focusNode, nodes[0]) + dispatch.call(focusNode, nodes[0], false) break case 'ArrowUp': DOMHelper.focusFileExplorer() - dispatch.call(focusNode, nodes[nodes.length - 1]) + dispatch.call(focusNode, nodes[nodes.length - 1], false) break default: muteEvent = false @@ -211,7 +211,7 @@ const handleKeyDown: MethodCreator< }) const onFocusSearchBar: MethodCreator = dispatch => () => - dispatch.call(focusNode, null) + dispatch.call(focusNode, null, false) const handleSearchKeyChange: MethodCreator< Props, @@ -240,7 +240,7 @@ const setExpand: MethodCreator = dis expand = false ) => { visibleNodesGenerator.setExpand(node, expand) - const applyChanges = () => dispatch.call(focusNode, node) + const applyChanges = () => dispatch.call(focusNode, node, false) if (shouldDelayExpand(node)) { dispatch.call(mountExpandingIndicator, node) tasksAfterRender.push(() => setTimeout(applyChanges, 0)) @@ -266,11 +266,10 @@ const toggleNodeExpansion: MethodCreator = dispatch => (node: TreeNode, skipScroll = false) => +const focusNode: MethodCreator = dispatch => ( + node: TreeNode | null, + skipScroll = false, +) => dispatch.get(({ visibleNodes: { nodes } }) => { visibleNodesGenerator.focusNode(node) if (node && !skipScroll) {