Skip to content

Commit

Permalink
#41 fix compound classes in compounds picker
Browse files Browse the repository at this point in the history
  • Loading branch information
tibor-postek-m2ms committed Mar 2, 2020
1 parent 17d6930 commit b47d810
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions js/components/preview/compounds/redux/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,15 @@ export const compounds = (state = INITIAL_STATE, action = {}) => {
return Object.assign({}, state, { showedCompoundList: [...diminishedCmpdsList] });

case constants.APPEND_SELECTED_COMPOUND_CLASS:
const selectedCmpdClass = new Set(state.selectedCompoundsClass[action.payload.classID]);
selectedCmpdClass[action.payload.classID].add(action.payload.compoundID);
const selectedCmpdClass = JSON.parse(JSON.stringify(state.selectedCompoundsClass));

const currentClassList = new Set(selectedCmpdClass[action.payload.classID]);
currentClassList.add(action.payload.compoundID);

selectedCmpdClass[action.payload.classID] = [...currentClassList];

return Object.assign({}, state, {
selectedCompoundsClass: { ...state.selectedCompoundsClass, [action.payload.classID]: [...selectedCmpdClass] }
selectedCompoundsClass: selectedCmpdClass
});

case constants.REMOVE_SELECTED_COMPOUND_CLASS:
Expand Down

0 comments on commit b47d810

Please sign in to comment.