Skip to content

Commit f979aa5

Browse files
author
Adriána Kohanová
committed
#510 Restoring a snapshot doesn't restore compounds displayed in vector selector
1 parent 3b61636 commit f979aa5

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

js/reducers/tracking/dispatchActions.js

+25-25
Original file line numberDiff line numberDiff line change
@@ -867,18 +867,18 @@ const restoreSitesActions = (orderedActionList, summaryView) => (dispatch, getSt
867867
}
868868
};
869869

870-
const restoreMoleculesActions = (orderedActionList, stage) => (dispatch, getState) => {
870+
const restoreMoleculesActions = (orderedActionList, stage) => async (dispatch, getState) => {
871871
const state = getState();
872872
let moleculesAction = orderedActionList.filter(
873873
action => action.object_type === actionObjectType.MOLECULE || action.object_type === actionObjectType.INSPIRATION
874874
);
875875

876876
if (moleculesAction) {
877-
dispatch(addNewType(moleculesAction, actionType.LIGAND_TURNED_ON, 'ligand', stage, state));
878-
dispatch(addNewType(moleculesAction, actionType.SIDECHAINS_TURNED_ON, 'protein', stage, state));
879-
dispatch(addNewType(moleculesAction, actionType.INTERACTIONS_TURNED_ON, 'complex', stage, state));
880-
dispatch(addNewType(moleculesAction, actionType.SURFACE_TURNED_ON, 'surface', stage, state));
881-
dispatch(addNewType(moleculesAction, actionType.VECTORS_TURNED_ON, 'vector', stage, state));
877+
await dispatch(addNewType(moleculesAction, actionType.LIGAND_TURNED_ON, 'ligand', stage, state));
878+
await dispatch(addNewType(moleculesAction, actionType.SIDECHAINS_TURNED_ON, 'protein', stage, state));
879+
await dispatch(addNewType(moleculesAction, actionType.INTERACTIONS_TURNED_ON, 'complex', stage, state));
880+
await dispatch(addNewType(moleculesAction, actionType.SURFACE_TURNED_ON, 'surface', stage, state));
881+
await dispatch(addNewType(moleculesAction, actionType.VECTORS_TURNED_ON, 'vector', stage, state));
882882
}
883883

884884
dispatch(restoreAllSelectionActions(orderedActionList, stage, true));
@@ -887,6 +887,21 @@ const restoreMoleculesActions = (orderedActionList, stage) => (dispatch, getStat
887887
};
888888

889889
const restoreCartActions = (orderedActionList, majorViewStage) => async (dispatch, getState) => {
890+
let classSelectedAction = orderedActionList.find(action => action.type === actionType.CLASS_SELECTED);
891+
if (classSelectedAction) {
892+
dispatch(setCurrentCompoundClass(classSelectedAction.value, classSelectedAction.oldValue));
893+
}
894+
895+
let classUpdatedAction = orderedActionList.find(action => action.type === actionType.CLASS_UPDATED);
896+
if (classUpdatedAction) {
897+
let id = classUpdatedAction.object_id;
898+
let newValue = classUpdatedAction.newCompoundClasses;
899+
let oldValue = classUpdatedAction.oldCompoundClasses;
900+
let value = classUpdatedAction.object_name;
901+
value = value !== undefined ? value : '';
902+
dispatch(setCompoundClasses(newValue, oldValue, value, id));
903+
}
904+
890905
let vectorAction = orderedActionList.find(action => action.type === actionType.VECTOR_SELECTED);
891906
if (vectorAction) {
892907
console.log('vector action: ' + JSON.stringify(vectorAction));
@@ -916,21 +931,6 @@ const restoreCartActions = (orderedActionList, majorViewStage) => async (dispatc
916931
});
917932
}
918933

919-
let classSelectedAction = orderedActionList.find(action => action.type === actionType.CLASS_SELECTED);
920-
if (classSelectedAction) {
921-
dispatch(setCurrentCompoundClass(classSelectedAction.value, classSelectedAction.oldValue));
922-
}
923-
924-
let classUpdatedAction = orderedActionList.find(action => action.type === actionType.CLASS_UPDATED);
925-
if (classUpdatedAction) {
926-
let id = classUpdatedAction.object_id;
927-
let newValue = classUpdatedAction.newCompoundClasses;
928-
let oldValue = classUpdatedAction.oldCompoundClasses;
929-
let value = classUpdatedAction.object_name;
930-
value = value !== undefined ? value : '';
931-
dispatch(setCompoundClasses(newValue, oldValue, value, id));
932-
}
933-
934934
let vectorCompoundActions = orderedActionList.filter(action => action.type === actionType.VECTOR_COUMPOUND_ADDED);
935935
if (vectorCompoundActions) {
936936
vectorCompoundActions.forEach(action => {
@@ -1148,21 +1148,21 @@ const addTypeCompound = {
11481148
surface: addDatasetSurface
11491149
};
11501150

1151-
const addNewType = (moleculesAction, actionType, type, stage, state, skipTracking = false) => dispatch => {
1151+
const addNewType = (moleculesAction, actionType, type, stage, state, skipTracking = false) => async dispatch => {
11521152
let actions = moleculesAction.filter(action => action.type === actionType);
11531153
if (actions) {
1154-
actions.forEach(action => {
1154+
for (const action of actions) {
11551155
let data = getMolecule(action.object_name, state);
11561156
if (data) {
11571157
if (type === 'ligand') {
11581158
dispatch(addType[type](stage, data, colourList[data.id % colourList.length], true, skipTracking));
11591159
} else if (type === 'vector') {
1160-
dispatch(addType[type](stage, data, true));
1160+
await dispatch(addType[type](stage, data, true));
11611161
} else {
11621162
dispatch(addType[type](stage, data, colourList[data.id % colourList.length], skipTracking));
11631163
}
11641164
}
1165-
});
1165+
}
11661166
}
11671167
};
11681168

0 commit comments

Comments
 (0)