@@ -336,7 +336,7 @@ const saveActionsList = (project, snapshot, actionList, nglViewList) => async (d
336
336
// getCollection(currentQualities),
337
337
// currentActions
338
338
// );
339
- getCurrentActionList (
339
+ getCurrentActionListDensity (
340
340
orderedActionList ,
341
341
actionType . DENSITY_TURNED_ON ,
342
342
getCollection ( currentDensities ) ,
@@ -348,8 +348,8 @@ const saveActionsList = (project, snapshot, actionList, nglViewList) => async (d
348
348
getCollection ( selectedMolecules ) ,
349
349
currentActions
350
350
) ;
351
- getCurrentActionList ( orderedActionList , actionType . DENSITY_TYPE_ON , currentDensitiesType , currentActions ) ;
352
- getCurrentActionList (
351
+ getCurrentActionListDensity ( orderedActionList , actionType . DENSITY_TYPE_ON , currentDensitiesType , currentActions ) ;
352
+ getCurrentActionListDensity (
353
353
orderedActionList ,
354
354
actionType . DENSITY_CUSTOM_TURNED_ON ,
355
355
getCollection ( currentDensitiesCustom ) ,
@@ -632,6 +632,20 @@ const getCurrentActionList = (orderedActionList, type, collection, currentAction
632
632
}
633
633
} ;
634
634
635
+ const getCurrentActionListDensity = ( orderedActionList , type , collection , currentActions ) => {
636
+ let actionList = orderedActionList . filter ( action => action . type === type ) ;
637
+
638
+ if ( collection ) {
639
+ collection . forEach ( data => {
640
+ const action = actionList . find ( a => a . object_id === data . id && a . dataset_id === data . datasetId ) ;
641
+
642
+ if ( action ) {
643
+ currentActions . push ( { ...action } ) ;
644
+ }
645
+ } ) ;
646
+ }
647
+ } ;
648
+
635
649
const getCommonLastActionByType = ( orderedActionList , type , currentActions ) => {
636
650
let action = orderedActionList . find ( action => action . type === type ) ;
637
651
if ( action ) {
@@ -1964,11 +1978,15 @@ const removeTypeCompound = {
1964
1978
surface : removeDatasetSurface
1965
1979
} ;
1966
1980
1967
- const addNewType = ( moleculesAction , actionType , type , stage , state , skipTracking = false ) => async dispatch => {
1981
+ const addNewType = ( moleculesAction , actionType , type , stage , state , skipTracking = false ) => async (
1982
+ dispatch ,
1983
+ getState
1984
+ ) => {
1968
1985
let actions = moleculesAction . filter ( action => action . type === actionType ) ;
1969
1986
if ( actions ) {
1970
1987
for ( const action of actions ) {
1971
- let data = getMolecule ( action . object_name , state ) ;
1988
+ const freshState = getState ( ) ;
1989
+ let data = getMolecule ( action . object_name , freshState ) ;
1972
1990
if ( data ) {
1973
1991
if ( type === 'ligand' ) {
1974
1992
await dispatch ( addType [ type ] ( stage , data , colourList [ data . id % colourList . length ] , true , true , skipTracking ) ) ;
@@ -1980,19 +1998,31 @@ const addNewType = (moleculesAction, actionType, type, stage, state, skipTrackin
1980
1998
if ( ! data . proteinData ) {
1981
1999
await dispatch ( getProteinData ( data ) ) . then ( i => {
1982
2000
const proteinData = i ;
1983
- data . proteinData = proteinData ;
2001
+ if ( type === 'density' ) {
2002
+ data . proteinData = proteinData ;
2003
+ data . proteinData . render_event = ! ! action . render_event ;
2004
+ data . proteinData . render_diff = ! ! action . render_diff ;
2005
+ data . proteinData . render_sigmaa = ! ! action . render_sigmaa ;
2006
+ data . proteinData . render_quality = ! ! action . render_quality ;
2007
+ }
2008
+ } ) ;
2009
+ if ( type === 'density' ) {
2010
+ await dispatch ( addType [ type ] ( stage , data , colourList [ data . id % colourList . length ] , true , skipTracking ) ) ;
2011
+ } else {
2012
+ await dispatch ( addType [ type ] ( stage , data , colourList [ data . id % colourList . length ] , true , skipTracking ) ) ;
2013
+ }
2014
+ } else {
2015
+ if ( type === 'density' ) {
1984
2016
data . proteinData . render_event = ! ! action . render_event ;
1985
2017
data . proteinData . render_diff = ! ! action . render_diff ;
1986
2018
data . proteinData . render_sigmaa = ! ! action . render_sigmaa ;
1987
2019
data . proteinData . render_quality = ! ! action . render_quality ;
1988
- } ) ;
1989
- await dispatch ( addType [ type ] ( stage , data , colourList [ data . id % colourList . length ] , true , skipTracking ) ) ;
1990
- } else {
1991
- data . proteinData . render_event = ! ! action . render_event ;
1992
- data . proteinData . render_diff = ! ! action . render_diff ;
1993
- data . proteinData . render_sigmaa = ! ! action . render_sigmaa ;
1994
- data . proteinData . render_quality = ! ! action . render_quality ;
1995
- await dispatch ( addType [ type ] ( stage , data , colourList [ data . id % colourList . length ] , true , skipTracking ) ) ;
2020
+ }
2021
+ if ( type === 'density' ) {
2022
+ await dispatch ( addType [ type ] ( stage , data , colourList [ data . id % colourList . length ] , true , skipTracking ) ) ;
2023
+ } else {
2024
+ await dispatch ( addType [ type ] ( stage , data , colourList [ data . id % colourList . length ] , true , skipTracking ) ) ;
2025
+ }
1996
2026
}
1997
2027
} else if ( type === 'quality' ) {
1998
2028
await dispatch ( removeType [ type ] ( stage , data , colourList [ data . id % colourList . length ] , skipTracking ) ) ;
0 commit comments