From 2bb6a6f3ce4c6529f66e4da414c2f7edf82e2cc1 Mon Sep 17 00:00:00 2001 From: Boris Kovar Date: Thu, 10 Dec 2020 14:58:06 +0100 Subject: [PATCH] - fixed some automatic merge problems --- js/components/preview/molecule/moleculeList.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/js/components/preview/molecule/moleculeList.js b/js/components/preview/molecule/moleculeList.js index abfbe0288..77f6eadd9 100644 --- a/js/components/preview/molecule/moleculeList.js +++ b/js/components/preview/molecule/moleculeList.js @@ -289,8 +289,20 @@ export const MoleculeList = memo(({ height, setFilterItemsHeight, filterItemsHei } }, [getJoinedMoleculeList, getAllMoleculeList, searchString]); - // Used for MoleculeListSortFilterDialog when using textSearch - const joinedMoleculeListsCopy = useMemo(() => [...joinedMoleculeLists], [joinedMoleculeLists]); + const addSelectedMoleculesFromUnselectedSites = useCallback((joinedMoleculeLists, list) => { + const result = [...joinedMoleculeLists]; + list?.forEach(moleculeID => { + const foundJoinedMolecule = result.find(mol => mol.id === moleculeID); + if (!foundJoinedMolecule) { + const molecule = getAllMoleculeList.find(mol => mol.id === moleculeID); + if (molecule) { + result.push(molecule); + } + } + }); + + return result; + }, [getAllMoleculeList]); joinedMoleculeLists = useMemo( () => addSelectedMoleculesFromUnselectedSites(joinedMoleculeLists, proteinList),