Skip to content

Commit

Permalink
#532 Vector-selector view not properly restored
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriána Kohanová committed Feb 9, 2021
1 parent 191ce97 commit 36bf528
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion js/components/preview/compounds/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const selectAllCompounds = () => (dispatch, getState) => {
smiles: currentVectorCompoundsFiltered[key][index][indexOfCompound].end,
vector: currentVectorCompoundsFiltered[key].vector.split('_')[0],
mol: smiles,
class: parseInt(currentCompoundClass),
class: currentCompoundClass,
compoundId: compoundId
};
items.push(thisObj);
Expand Down
20 changes: 17 additions & 3 deletions js/reducers/tracking/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ const saveActionsList = (project, snapshot, actionList, nglViewList) => async (d
currentActions
);

getCurrentActionList(
getCurrentActionListOfShoppingCart(
orderedActionList,
actionType.MOLECULE_ADDED_TO_SHOPPING_CART,
getCollectionOfShoppingCart(currentBuyList),
Expand Down Expand Up @@ -568,13 +568,27 @@ const getCurrentActionListOfAllSelectionByTypeOfDataset = (
}
};

const getCurrentActionListOfShoppingCart = (orderedActionList, type, collection, currentActions) => {
let actionList = orderedActionList.filter(action => action.type === type);

if (collection) {
collection.forEach(data => {
let action = actionList.find(action => action.object_id === data.id && action.compoundId === data.compoundId);

if (action) {
currentActions.push(Object.assign({ ...action }));
}
});
}
};

const getCurrentActionListOfAllShopingCart = (orderedActionList, type, collection, currentActions) => {
let action = orderedActionList.find(action => action.type === type);
if (action && collection) {
let actionItems = action.items;
let items = [];
collection.forEach(data => {
let item = actionItems.find(action => action.vector === data.id);
let item = actionItems.find(i => i.vector === data.id && i.compoundId === data.compoundId);
if (item) {
items.push(item);
}
Expand Down Expand Up @@ -613,7 +627,7 @@ const getCollectionOfShoppingCart = dataList => {
dataList.forEach(data => {
let value = data.vector;
if (value) {
list.push({ id: value });
list.push({ id: value, compoundId: data.compoundId });
}
});
}
Expand Down

0 comments on commit 36bf528

Please sign in to comment.