Skip to content

Commit

Permalink
LPC buttons fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ag-m2ms committed Nov 12, 2020
1 parent 3dac0f5 commit 81f3533
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions js/components/preview/molecule/moleculeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,18 +439,26 @@ export const MoleculeList = memo(({ height, setFilterItemsHeight, filterItemsHei
handleFilterChange(newFilter);*/
};

const changeButtonClassname = (givenList = []) => {
if (joinedMoleculeLists.length === givenList.length) {
const joinedGivenMatch = useCallback((givenList) => {
return givenList.filter(element => joinedMoleculeLists.filter(element2 => element2.id === element).length > 0).length;
}, [joinedMoleculeLists]);

const joinedLigandMatchLength = useMemo(() => joinedGivenMatch(fragmentDisplayList), [fragmentDisplayList, joinedGivenMatch]);
const joinedProteinMatchLength = useMemo(() => joinedGivenMatch(proteinList), [proteinList, joinedGivenMatch]);
const joinedComplexMatchLength = useMemo(() => joinedGivenMatch(complexList), [complexList, joinedGivenMatch]);

const changeButtonClassname = (givenList = [], matchListLength) => {
if (joinedMoleculeLists.length === matchListLength) {
return true;
} else if (givenList.length > 0) {
} else if (givenList.length > 0 && matchListLength > 0) {
return null;
}
return false;
};

const isLigandOn = changeButtonClassname(fragmentDisplayList);
const isProteinOn = changeButtonClassname(proteinList);
const isComplexOn = changeButtonClassname(complexList);
const isLigandOn = changeButtonClassname(fragmentDisplayList, joinedLigandMatchLength);
const isProteinOn = changeButtonClassname(proteinList, joinedProteinMatchLength);
const isComplexOn = changeButtonClassname(complexList, joinedComplexMatchLength);

const addType = {
ligand: addLigand,
Expand Down

0 comments on commit 81f3533

Please sign in to comment.