1
- import { setCurrentActionsList } from './actions' ;
1
+ import { setCurrentActionsList , setIsTrackingMoleculesRestoring , setIsTrackingCompoundsRestoring } from './actions' ;
2
2
import { actionType , actionObjectType } from './constants' ;
3
3
import { VIEWS } from '../../../js/constants/constants' ;
4
4
import { setCurrentVector } from '../selection/actions' ;
@@ -24,7 +24,10 @@ import {
24
24
loadDataSets ,
25
25
loadDatasetCompoundsWithScores
26
26
} from '../../components/datasets/redux/dispatchActions' ;
27
- import { appendMoleculeToCompoundsOfDatasetToBuy } from '../../components/datasets/redux/actions' ;
27
+ import {
28
+ appendMoleculeToCompoundsOfDatasetToBuy ,
29
+ setMoleculeListIsLoading
30
+ } from '../../components/datasets/redux/actions' ;
28
31
import { setAllMolLists } from '../api/actions' ;
29
32
import { getUrl , loadAllMolsFromMolGroup } from '../../../js/utils/genericList' ;
30
33
import * as listType from '../../constants/listTypes' ;
@@ -157,7 +160,8 @@ const mapCurrentAction = action => {
157
160
timestamp : action . timestamp ,
158
161
object_name : action . object_name ,
159
162
object_type : action . object_type ,
160
- action_type : action . type
163
+ action_type : action . type ,
164
+ dataset_id : action . dataset_id
161
165
} ) ;
162
166
} ;
163
167
@@ -212,6 +216,8 @@ const getCollectionOfDatasetOfRepresentation = dataList => {
212
216
} ;
213
217
214
218
export const restoreCurrentActionsList = ( stages = [ ] ) => ( dispatch , getState ) => {
219
+ dispatch ( setIsTrackingMoleculesRestoring ( true ) ) ;
220
+ dispatch ( setIsTrackingCompoundsRestoring ( true ) ) ;
215
221
dispatch ( unmountPreviewComponent ( stages ) ) ;
216
222
dispatch ( resetTargetState ( ) ) ;
217
223
dispatch ( restoreStateBySavedActionList ( stages ) ) ;
@@ -226,9 +232,10 @@ const restoreStateBySavedActionList = stages => (dispatch, getState) => {
226
232
dispatch ( restoreTargetActions ( orderedActionList , stages ) ) ;
227
233
} ;
228
234
229
- const restoreTargetActions = ( orderedActionList , stages , state ) => ( dispatch , getState ) => {
235
+ const restoreTargetActions = ( orderedActionList , stages ) => ( dispatch , getState ) => {
230
236
const state = getState ( ) ;
231
237
238
+ const majorView = stages . find ( view => view . id === VIEWS . MAJOR_VIEW ) ;
232
239
const summaryView = stages . find ( view => view . id === VIEWS . SUMMARY_VIEW ) ;
233
240
234
241
let targetAction = orderedActionList . find ( action => action . action_type === actionType . TARGET_LOADED ) ;
@@ -250,32 +257,28 @@ const restoreTargetActions = (orderedActionList, stages, state) => (dispatch, ge
250
257
throw error ;
251
258
} )
252
259
. finally ( ( ) => {
253
- const majorView = stages . find ( view => view . id === VIEWS . MAJOR_VIEW ) ;
254
- const stage = majorView . stage ;
255
-
256
260
dispatch ( restoreSitesActions ( orderedActionList , summaryView ) ) ;
257
- dispatch ( loadAllMolecules ( orderedActionList , target . id , stage ) ) ;
261
+ dispatch ( loadAllMolecules ( orderedActionList , target . id , majorView . stage ) ) ;
258
262
} ) ;
259
263
260
- dispatch ( loadAllDatasaets ) ;
264
+ dispatch ( loadAllDatasets ( orderedActionList , target . id , majorView . stage ) ) ;
261
265
}
262
266
}
263
267
} ;
264
268
265
- const loadAllDatasaets = ( orderedActionList , target_on , stage ) => ( dispatch , getState ) => {
266
- // dispatch(setMoleculeListIsLoading(true));
269
+ const loadAllDatasets = ( orderedActionList , target_on , stage ) => ( dispatch , getState ) => {
270
+ dispatch ( setMoleculeListIsLoading ( true ) ) ;
267
271
dispatch ( loadDataSets ( target_on ) )
268
272
. then ( results => {
269
- //setSelectedDatasetIndex(0);
270
-
271
273
return dispatch ( loadDatasetCompoundsWithScores ( ) ) ;
272
274
} )
273
275
. catch ( error => {
274
276
throw new Error ( error ) ;
275
277
} )
276
278
. finally ( ( ) => {
277
- //dispatch(setMoleculeListIsLoading(false));
278
279
dispatch ( restoreCompoundsActions ( orderedActionList , stage ) ) ;
280
+ dispatch ( setMoleculeListIsLoading ( false ) ) ;
281
+ dispatch ( setIsTrackingCompoundsRestoring ( false ) ) ;
279
282
} ) ;
280
283
} ;
281
284
@@ -304,6 +307,7 @@ const loadAllMolecules = (orderedActionList, target_on, stage) => (dispatch, get
304
307
} ) ;
305
308
dispatch ( setAllMolLists ( listToSet ) ) ;
306
309
dispatch ( restoreMoleculesActions ( orderedActionList , stage ) ) ;
310
+ dispatch ( setIsTrackingMoleculesRestoring ( false ) ) ;
307
311
} )
308
312
. catch ( err => console . log ( err ) ) ;
309
313
} ;
@@ -390,7 +394,7 @@ const addNewType = (moleculesAction, actionType, type, stage, state) => dispatch
390
394
actions . forEach ( action => {
391
395
let data = getMolecule ( action . object_name , state ) ;
392
396
if ( data ) {
393
- dispatch ( addType [ type ] ( stage , data , colourList [ data . id % colourList . length ] ) , true ) ;
397
+ dispatch ( addType [ type ] ( stage , data , colourList [ data . id % colourList . length ] ) ) ;
394
398
}
395
399
} ) ;
396
400
}
@@ -402,7 +406,7 @@ const addNewTypeCompound = (moleculesAction, actionType, type, stage, state) =>
402
406
actions . forEach ( action => {
403
407
let data = getCompound ( action . object_name , state ) ;
404
408
if ( data ) {
405
- dispatch ( addTypeCompound [ type ] ( stage , data , colourList [ data . id % colourList . length ] ) , data . datasetID ) ;
409
+ dispatch ( addTypeCompound [ type ] ( stage , data , colourList [ data . id % colourList . length ] , action . dataset_id ) ) ;
406
410
}
407
411
} ) ;
408
412
}
0 commit comments