diff --git a/js/components/preview/compounds/compoundList.js b/js/components/preview/compounds/compoundList.js index 8e9b14308..30a495b6a 100644 --- a/js/components/preview/compounds/compoundList.js +++ b/js/components/preview/compounds/compoundList.js @@ -2,7 +2,7 @@ * Created by abradley on 15/03/2018. */ import React, { memo, useContext, useRef } from 'react'; -import { useDispatch, useSelector, shallowEqual } from 'react-redux'; +import { useDispatch, useSelector } from 'react-redux'; import { CompoundView } from './compoundView'; import { Panel } from '../../common/Surfaces/Panel'; import { Button } from '../../common/Inputs/Button'; diff --git a/js/components/preview/compounds/redux/actions.js b/js/components/preview/compounds/redux/actions.js index aa605afe7..e918113cb 100644 --- a/js/components/preview/compounds/redux/actions.js +++ b/js/components/preview/compounds/redux/actions.js @@ -1,4 +1,5 @@ import { constants } from './constants'; +import { compounds } from './reducer'; export const setCurrentCompounds = loadedCompounds => ({ type: constants.SET_CURRENT_COMPOUNDS, @@ -74,3 +75,8 @@ export const removeSelectedCompoundClass = compoundID => ({ export const resetSelectedCompoundClass = () => ({ type: constants.RESET_SELECTED_COMPOUND_CLASS }); + +export const reloadCompoundsReducer = newState => ({ + type: constants.RELOAD_REDUCER, + payload: newState +}); diff --git a/js/components/preview/compounds/redux/constants.js b/js/components/preview/compounds/redux/constants.js index f8f5fd562..84e85da09 100644 --- a/js/components/preview/compounds/redux/constants.js +++ b/js/components/preview/compounds/redux/constants.js @@ -17,7 +17,9 @@ export const constants = { APPEND_SELECTED_COMPOUND_CLASS: prefix + 'APPEND_SELECTED_COMPOUND_CLASS', REMOVE_SELECTED_COMPOUND_CLASS: prefix + 'REMOVE_SELECTED_COMPOUND_CLASS', - RESET_SELECTED_COMPOUND_CLASS: prefix + 'RESET_SELECTED_COMPOUND_CLASS' + RESET_SELECTED_COMPOUND_CLASS: prefix + 'RESET_SELECTED_COMPOUND_CLASS', + + RELOAD_REDUCER: prefix + 'RELOAD_REDUCER' }; const colors = { diff --git a/js/components/preview/compounds/redux/reducer.js b/js/components/preview/compounds/redux/reducer.js index fe6a2bd77..007c1e9c1 100644 --- a/js/components/preview/compounds/redux/reducer.js +++ b/js/components/preview/compounds/redux/reducer.js @@ -130,6 +130,9 @@ export const compounds = (state = INITIAL_STATE, action = {}) => { selectedCompoundsClass: defaultSelectedCmpdsClass }); + case constants.RELOAD_REDUCER: + return Object.assign({}, state, { ...action.payload }); + default: return state; } diff --git a/js/components/preview/molecule/moleculeList.js b/js/components/preview/molecule/moleculeList.js index 33389ffe8..35358f855 100644 --- a/js/components/preview/molecule/moleculeList.js +++ b/js/components/preview/molecule/moleculeList.js @@ -4,7 +4,7 @@ import { Grid, Chip, Tooltip, makeStyles, CircularProgress, Divider, Typography } from '@material-ui/core'; import { FilterList } from '@material-ui/icons'; -import React, { useState, useEffect, memo, useRef, useContext } from 'react'; +import React, { useState, useEffect, memo, useRef } from 'react'; import { connect } from 'react-redux'; import * as apiActions from '../../../reducers/api/actions'; import * as listType from '../../../constants/listTypes'; @@ -19,8 +19,6 @@ import { Panel } from '../../common/Surfaces/Panel'; import { ComputeSize } from '../../../utils/computeSize'; import { moleculeProperty } from './helperConstants'; import { setSortDialogOpen } from './redux/actions'; -import { VIEWS } from '../../../constants/constants'; -import { NglContext } from '../../nglView/nglProvider'; const useStyles = makeStyles(theme => ({ container: { @@ -122,9 +120,6 @@ const MoleculeList = memo( const imgHeight = 34; const imgWidth = 150; - const { getNglView } = useContext(NglContext); - const stage = getNglView(VIEWS.MAJOR_VIEW) && getNglView(VIEWS.MAJOR_VIEW).stage; - const isActiveFilter = !!(filterSettings || {}).active; const filterRef = useRef(); diff --git a/js/components/preview/molecule/redux/actions.js b/js/components/preview/molecule/redux/actions.js index 5b1eac5e9..577e64328 100644 --- a/js/components/preview/molecule/redux/actions.js +++ b/js/components/preview/molecule/redux/actions.js @@ -4,3 +4,8 @@ export const setSortDialogOpen = isOpen => ({ type: constants.SET_SORT_DIALOG_OPEN, payload: isOpen }); + +export const reloadMoleculeReducer = newState => ({ + type: constants.SET_SORT_DIALOG_OPEN, + payload: newState +}); diff --git a/js/components/preview/molecule/redux/constants.js b/js/components/preview/molecule/redux/constants.js index 6603457e4..d1da20c78 100644 --- a/js/components/preview/molecule/redux/constants.js +++ b/js/components/preview/molecule/redux/constants.js @@ -1,5 +1,7 @@ const prefix = 'PREVIEW_MOLECULE_'; export const constants = { - SET_SORT_DIALOG_OPEN: prefix + 'SET_SORT_DIALOG_OPEN' + SET_SORT_DIALOG_OPEN: prefix + 'SET_SORT_DIALOG_OPEN', + + RELOAD_REDUCER: prefix + 'RELOAD_REDUCER' }; diff --git a/js/components/preview/molecule/redux/reducer.js b/js/components/preview/molecule/redux/reducer.js index 658d8ba77..4c6311f50 100644 --- a/js/components/preview/molecule/redux/reducer.js +++ b/js/components/preview/molecule/redux/reducer.js @@ -11,6 +11,9 @@ export const molecule = (state = INITIAL_STATE, action = {}) => { sortDialogOpen: action.payload }); + case constants.RELOAD_REDUCER: + return Object.assign({}, state, { ...action.payload }); + default: return state; } diff --git a/js/components/preview/redux/dispatchActions.js b/js/components/preview/redux/dispatchActions.js index 10612bcf7..5756a0fb1 100644 --- a/js/components/preview/redux/dispatchActions.js +++ b/js/components/preview/redux/dispatchActions.js @@ -1,6 +1,9 @@ import { generateProteinObject } from '../../nglView/generatingObjects'; import { SUFFIX, VIEWS } from '../../../constants/constants'; import { loadObject, setProteinsHasLoaded, setOrientation } from '../../../reducers/ngl/dispatchActions'; +import { reloadSummaryReducer } from '../summary/redux/actions'; +import { reloadCompoundsReducer } from '../compounds/redux/actions'; +import { reloadMoleculeReducer } from '../molecule/redux/actions'; const loadProtein = nglView => (dispatch, getState) => { const state = getState(); @@ -52,3 +55,9 @@ export const shouldLoadProtein = (nglViewList, isStateLoaded) => (dispatch, getS } } }; + +export const reloadPreviewReducer = newState => dispatch => { + dispatch(reloadSummaryReducer(newState.summary)); + dispatch(reloadCompoundsReducer(newState.compounds)); + // dispatch(reloadMoleculeReducer(newState.molecule)); +}; diff --git a/js/components/preview/summary/redux/actions.js b/js/components/preview/summary/redux/actions.js index 288681153..c79cda469 100644 --- a/js/components/preview/summary/redux/actions.js +++ b/js/components/preview/summary/redux/actions.js @@ -14,3 +14,5 @@ export const setCountOfExploredVectors = count => ({ type: constants.SET_COUNT_O export const setCountOfExploredSeries = count => ({ type: constants.SET_COUNT_OF_EXPLORED_SERIES, payload: count }); export const setEstimatedCost = count => ({ type: constants.SET_ESTIMATED_COST, payload: count }); export const setSelectedInteraction = count => ({ type: constants.SET_SELECTED_INTERACTION, payload: count }); + +export const reloadSummaryReducer = newState => ({ type: constants.RELOAD_REDUCER, payload: newState }); diff --git a/js/components/preview/summary/redux/constants.js b/js/components/preview/summary/redux/constants.js index 403410022..72e8fb4b3 100644 --- a/js/components/preview/summary/redux/constants.js +++ b/js/components/preview/summary/redux/constants.js @@ -11,5 +11,7 @@ export const constants = { SET_COUNT_OF_EXPLORED_VECTORS: prefix + 'SET_COUNT_OF_EXPLORED_VECTORS', SET_COUNT_OF_EXPLORED_SERIES: prefix + 'SET_COUNT_OF_EXPLORED_SERIES', SET_ESTIMATED_COST: prefix + 'SET_ESTIMATED_COST', - SET_SELECTED_INTERACTION: prefix + 'SET_SELECTED_INTERACTION' + SET_SELECTED_INTERACTION: prefix + 'SET_SELECTED_INTERACTION', + + RELOAD_REDUCER: prefix + 'RELOAD_REDUCER' }; diff --git a/js/components/preview/summary/redux/reducer.js b/js/components/preview/summary/redux/reducer.js index 14af7f8e8..9e1ce9a02 100644 --- a/js/components/preview/summary/redux/reducer.js +++ b/js/components/preview/summary/redux/reducer.js @@ -57,6 +57,9 @@ export const summary = (state = INITIAL_STATE, action = {}) => { case constants.SET_SELECTED_INTERACTION: return Object.assign({}, state, { selectedInteraction: action.payload }); + case constants.RELOAD_REDUCER: + return Object.assign({}, state, { ...action.payload }); + default: return state; } diff --git a/js/components/session/redux/dispatchActions.js b/js/components/session/redux/dispatchActions.js index ff26fb74d..8ca0818d0 100644 --- a/js/components/session/redux/dispatchActions.js +++ b/js/components/session/redux/dispatchActions.js @@ -18,6 +18,14 @@ import { savingStateConst, savingTypeConst } from '../constants'; import { setLoadedSession, setNewSessionFlag, setNextUUID, setSaveType } from './actions'; import { getStore } from '../../helpers/globalStore'; import { DJANGO_CONTEXT } from '../../../utils/djangoContext'; +import apiReducers from '../../../reducers/api/apiReducers'; +import nglReducers from '../../../reducers/ngl/nglReducers'; +import selectionReducers from '../../../reducers/selection/selectionReducers'; +import { targetReducers } from '../../target/redux/reducer'; +import { sessionReducers } from './reducer'; +import { previewReducers } from '../../preview/redux'; +import { issueReducers } from '../../userFeedback/redux/reducer'; +import { reloadPreviewReducer } from '../../preview/redux/dispatchActions'; export const handleVector = json => dispatch => { let objList = generateObjectList(json['3d']); @@ -53,6 +61,8 @@ export const reloadSession = (myJson, nglViewList) => dispatch => { dispatch(redeployVectorsLocal(url)).catch(error => { throw new Error(error); }); + + dispatch(reloadPreviewReducer(jsonOfView.previewReducers)); } } }; @@ -168,7 +178,8 @@ export const reloadScene = ({ saveType, newSessionFlag, nextUuid, uuid, sessionI state: JSON.stringify({ apiReducers: newPresentObject, nglReducers: stateObject.nglReducers, - selectionReducers: stateObject.selectionReducers + selectionReducers: stateObject.selectionReducers, + previewReducers: stateObject.previewReducers }) };