@@ -889,6 +889,7 @@ export const resetRestoringState = () => (dispatch, getState) => {
889
889
} ;
890
890
891
891
export const restoreCurrentActionsList = snapshotID => async ( dispatch , getState ) => {
892
+ const state = getState ( ) ;
892
893
dispatch ( resetTrackingState ( ) ) ;
893
894
dispatch ( resetTargetState ( ) ) ;
894
895
dispatch ( setTargetOn ( undefined ) ) ;
@@ -904,25 +905,34 @@ export const restoreCurrentActionsList = snapshotID => async (dispatch, getState
904
905
} ;
905
906
906
907
const restoreTrackingActions = snapshotID => async ( dispatch , getState ) => {
908
+ // console.log(`snapshotDebug - restoreTrackingActions - start`);
907
909
if ( snapshotID ) {
908
910
try {
909
- const response = await api ( {
911
+ // console.log(`snapshotDebug - restoreTrackingActions - before getting actions`);
912
+ return api ( {
910
913
url : `${ base_url } /api/snapshot-actions/?snapshot=${ snapshotID } `
911
- } ) ;
912
- let results = response . data . results ;
913
- let listToSet = [ ] ;
914
- results . forEach ( r => {
915
- let resultActions = JSON . parse ( r . actions ) ;
916
- listToSet . push ( ...resultActions ) ;
917
- } ) ;
914
+ } ) . then ( response => {
915
+ // console.log(`snapshotDebug - restoreTrackingActions - after getting actions`);
916
+ let results = response . data . results ;
917
+ // console.log(`snapshotDebug - restoreTrackingActions - no. of actions: ${results.length}`);
918
+ let listToSet = [ ] ;
919
+ results . forEach ( r => {
920
+ let resultActions = JSON . parse ( r . actions ) ;
921
+ listToSet . push ( ...resultActions ) ;
922
+ } ) ;
918
923
919
- let snapshotActions = [ ...listToSet ] ;
920
- dispatch ( setCurrentActionsList ( snapshotActions ) ) ;
924
+ let snapshotActions = [ ...listToSet ] ;
925
+ dispatch ( setCurrentActionsList ( snapshotActions ) ) ;
926
+ // console.log(`snapshotDebug - restoreTrackingActions - end - success`);
927
+ return Promise . resolve ( snapshotActions ) ;
928
+ // return Promise.resolve();
929
+ } ) ;
921
930
} catch ( error ) {
922
931
throw new Error ( error ) ;
923
932
}
924
933
} else {
925
- return Promise . resolve ( ) ;
934
+ // console.log(`snapshotDebug - restoreTrackingActions - end - no snapshot`);
935
+ return Promise . resolve ( [ ] ) ;
926
936
}
927
937
} ;
928
938
@@ -958,11 +968,14 @@ const restoreTargetActions = orderedActionList => (dispatch, getState) => {
958
968
}
959
969
} ;
960
970
961
- export const restoreAfterTargetActions = ( stages , projectId ) => async ( dispatch , getState ) => {
971
+ export const restoreAfterTargetActions = ( stages , projectId , snapshotId ) => async ( dispatch , getState ) => {
972
+ const currentActionList = await dispatch ( restoreTrackingActions ( snapshotId ) ) ;
973
+
962
974
const state = getState ( ) ;
963
975
964
- const currentActionList = state . trackingReducers . current_actions_list ;
976
+ // const currentActionList = state.trackingReducers.current_actions_list;
965
977
const orderedActionList = currentActionList . sort ( ( a , b ) => a . timestamp - b . timestamp ) ;
978
+ // console.log(`snapshotDebug - restoreAfterTargetActions - no. of actions: ${orderedActionList.length}`);
966
979
const targetId = state . apiReducers . target_on ;
967
980
968
981
if ( targetId && stages && stages . length > 0 ) {
@@ -983,8 +996,12 @@ export const restoreAfterTargetActions = (stages, projectId) => async (dispatch,
983
996
. finally ( ( ) => { } ) ;
984
997
985
998
await dispatch ( restoreSitesActions ( orderedActionList ) ) ;
999
+ // console.log(`snapshotDebug - restoreAfterTargetActions - before loadData`);
986
1000
await dispatch ( loadData ( orderedActionList , targetId , majorView ) ) ;
1001
+ // console.log(`snapshotDebug - restoreAfterTargetActions - after loadData`);
1002
+ // console.log(`snapshotDebug - restoreAfterTargetActions - before restoreTagActions`);
987
1003
await dispatch ( restoreTagActions ( orderedActionList ) ) ;
1004
+ // console.log(`snapshotDebug - restoreAfterTargetActions - after restoreTagActions`);
988
1005
await dispatch ( restoreMoleculesActions ( orderedActionList , majorView . stage ) ) ;
989
1006
await dispatch ( restoreRepresentationActions ( orderedActionList , stages ) ) ;
990
1007
await dispatch ( restoreProject ( projectId ) ) ;
@@ -1385,8 +1402,12 @@ export const restoreNglOrientationAnim = (orderedActionList, stages) => async (d
1385
1402
} ;
1386
1403
1387
1404
const loadData = ( orderedActionList , targetId , majorView ) => async ( dispatch , getState ) => {
1405
+ // console.log(`snapshotDebug - loadData - before loadAllMolecules`);
1388
1406
await dispatch ( loadAllMolecules ( targetId ) ) ;
1407
+ // console.log(`snapshotDebug - loadData - after loadAllMolecules`);
1408
+ // console.log(`snapshotDebug - loadData - before loadAllDatasets`);
1389
1409
await dispatch ( loadAllDatasets ( orderedActionList , targetId , majorView . stage ) ) ;
1410
+ // console.log(`snapshotDebug - loadData - after loadAllDatasets`);
1390
1411
} ;
1391
1412
1392
1413
const loadAllDatasets = ( orderedActionList , target_on , stage ) => async ( dispatch , getState ) => {
0 commit comments