@@ -867,18 +867,18 @@ const restoreSitesActions = (orderedActionList, summaryView) => (dispatch, getSt
867
867
}
868
868
} ;
869
869
870
- const restoreMoleculesActions = ( orderedActionList , stage ) => ( dispatch , getState ) => {
870
+ const restoreMoleculesActions = ( orderedActionList , stage ) => async ( dispatch , getState ) => {
871
871
const state = getState ( ) ;
872
872
let moleculesAction = orderedActionList . filter (
873
873
action => action . object_type === actionObjectType . MOLECULE || action . object_type === actionObjectType . INSPIRATION
874
874
) ;
875
875
876
876
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 ) ) ;
882
882
}
883
883
884
884
dispatch ( restoreAllSelectionActions ( orderedActionList , stage , true ) ) ;
@@ -887,6 +887,21 @@ const restoreMoleculesActions = (orderedActionList, stage) => (dispatch, getStat
887
887
} ;
888
888
889
889
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
+
890
905
let vectorAction = orderedActionList . find ( action => action . type === actionType . VECTOR_SELECTED ) ;
891
906
if ( vectorAction ) {
892
907
console . log ( 'vector action: ' + JSON . stringify ( vectorAction ) ) ;
@@ -916,21 +931,6 @@ const restoreCartActions = (orderedActionList, majorViewStage) => async (dispatc
916
931
} ) ;
917
932
}
918
933
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
-
934
934
let vectorCompoundActions = orderedActionList . filter ( action => action . type === actionType . VECTOR_COUMPOUND_ADDED ) ;
935
935
if ( vectorCompoundActions ) {
936
936
vectorCompoundActions . forEach ( action => {
@@ -1148,21 +1148,21 @@ const addTypeCompound = {
1148
1148
surface : addDatasetSurface
1149
1149
} ;
1150
1150
1151
- const addNewType = ( moleculesAction , actionType , type , stage , state , skipTracking = false ) => dispatch => {
1151
+ const addNewType = ( moleculesAction , actionType , type , stage , state , skipTracking = false ) => async dispatch => {
1152
1152
let actions = moleculesAction . filter ( action => action . type === actionType ) ;
1153
1153
if ( actions ) {
1154
- actions . forEach ( action => {
1154
+ for ( const action of actions ) {
1155
1155
let data = getMolecule ( action . object_name , state ) ;
1156
1156
if ( data ) {
1157
1157
if ( type === 'ligand' ) {
1158
1158
dispatch ( addType [ type ] ( stage , data , colourList [ data . id % colourList . length ] , true , skipTracking ) ) ;
1159
1159
} else if ( type === 'vector' ) {
1160
- dispatch ( addType [ type ] ( stage , data , true ) ) ;
1160
+ await dispatch ( addType [ type ] ( stage , data , true ) ) ;
1161
1161
} else {
1162
1162
dispatch ( addType [ type ] ( stage , data , colourList [ data . id % colourList . length ] , skipTracking ) ) ;
1163
1163
}
1164
1164
}
1165
- } ) ;
1165
+ }
1166
1166
}
1167
1167
} ;
1168
1168
0 commit comments