X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/f0ac109691369516a5adf9370838cb4eacf16a45..a459a376f98f7cb8741c8ab1057c9578e59dc327:/src/store/collection-panel/collection-panel-files/collection-panel-files-reducer.ts?ds=inline diff --git a/src/store/collection-panel/collection-panel-files/collection-panel-files-reducer.ts b/src/store/collection-panel/collection-panel-files/collection-panel-files-reducer.ts index 2a3aac74..57961538 100644 --- a/src/store/collection-panel/collection-panel-files/collection-panel-files-reducer.ts +++ b/src/store/collection-panel/collection-panel-files/collection-panel-files-reducer.ts @@ -2,15 +2,15 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { CollectionPanelFilesState, CollectionPanelFile, CollectionPanelDirectory, mapCollectionFileToCollectionPanelFile } from "./collection-panel-files-state"; +import { CollectionPanelFilesState, CollectionPanelFile, CollectionPanelDirectory, mapCollectionFileToCollectionPanelFile, mergeCollectionPanelFilesStates } from './collection-panel-files-state'; import { CollectionPanelFilesAction, collectionPanelFilesAction } from "./collection-panel-files-actions"; -import { createTree, mapTreeValues, getNode, setNode, getNodeAncestors, getNodeDescendants, setNodeValueWith, mapTree } from "~/models/tree"; +import { createTree, mapTreeValues, getNode, setNode, getNodeAncestorsIds, getNodeDescendantsIds, setNodeValueWith, mapTree } from "~/models/tree"; import { CollectionFileType } from "~/models/collection-file"; export const collectionPanelFilesReducer = (state: CollectionPanelFilesState = createTree(), action: CollectionPanelFilesAction) => { return collectionPanelFilesAction.match(action, { SET_COLLECTION_FILES: files => - mapTree(mapCollectionFileToCollectionPanelFile)(files), + mergeCollectionPanelFilesStates(state, mapTree(mapCollectionFileToCollectionPanelFile)(files)), TOGGLE_COLLECTION_FILE_COLLAPSE: data => toggleCollapse(data.id)(state), @@ -44,7 +44,7 @@ const toggleSelected = (id: string) => (tree: CollectionPanelFilesState) => const toggleDescendants = (id: string) => (tree: CollectionPanelFilesState) => { const node = getNode(id)(tree); if (node && node.value.type === CollectionFileType.DIRECTORY) { - return getNodeDescendants(id)(tree) + return getNodeDescendantsIds(id)(tree) .reduce((newTree, id) => setNodeValueWith(v => ({ ...v, selected: node.value.selected }))(id)(newTree), tree); } @@ -52,7 +52,7 @@ const toggleDescendants = (id: string) => (tree: CollectionPanelFilesState) => { }; const toggleAncestors = (id: string) => (tree: CollectionPanelFilesState) => { - const ancestors = getNodeAncestors(id)(tree).reverse(); + const ancestors = getNodeAncestorsIds(id)(tree).reverse(); return ancestors.reduce((newTree, parent) => parent ? toggleParentNode(parent)(newTree) : newTree, tree); };