Skip to content

Commit

Permalink
#267 moved logic from rebase to follow right side changes
Browse files Browse the repository at this point in the history
  • Loading branch information
matej-vavrek committed Apr 30, 2020
1 parent 1ad5079 commit 91ea286
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 56 deletions.
10 changes: 8 additions & 2 deletions js/components/preview/molecule/hitNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { MoleculeList } from './moleculeList';
import { hideAllSelectedMolecules, initializeMolecules } from './redux/dispatchActions';
import { PREDEFINED_FILTERS, DEFAULT_FILTER } from '../../../reducers/selection/constants';
import { initializeDatasetMoleculeLists } from '../../datasets/redux/dispatchActions';
import { useRouteMatch } from 'react-router-dom';

const useStyles = makeStyles(theme => ({
formControl: {
Expand Down Expand Up @@ -74,6 +75,9 @@ const HitNavigator = memo(
oldUrl.current = url;
};

let match = useRouteMatch();
const target = match && match.params && match.params.target;

const isActiveFilter = !!(filterSettings || {}).active;
const [sortDialogAnchorEl, setSortDialogAnchorEl] = useState(null);
const [currentMolecules, setCurrentMolecules] = useState(null);
Expand Down Expand Up @@ -121,7 +125,8 @@ const HitNavigator = memo(
cached_mol_lists[mol_group_on] &&
firstLoadRef &&
firstLoadRef.current &&
hideProjects
hideProjects &&
target !== undefined
) {
console.log('initializing molecules');
firstLoadRef.current = false;
Expand All @@ -141,8 +146,9 @@ const HitNavigator = memo(
target_on,
setCachedMolLists,
cached_mol_lists,
dispatch,
hideProjects,
dispatch
target
]);

useEffect(() => {
Expand Down
54 changes: 0 additions & 54 deletions js/components/preview/molecule/moleculeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
addLigand,
removeLigand
} from './redux/dispatchActions';
import { useRouteMatch } from 'react-router-dom';

const useStyles = makeStyles(theme => ({
container: {
Expand Down Expand Up @@ -162,8 +161,6 @@ export const MoleculeList = memo(
const imgHeight = 34;
const imgWidth = 150;
const sortDialogOpen = useSelector(state => state.previewReducers.molecule.sortDialogOpen);
let match = useRouteMatch();
const target = match && match.params && match.params.target;

const isActiveFilter = !!(filterSettings || {}).active;

Expand Down Expand Up @@ -192,57 +189,6 @@ export const MoleculeList = memo(
setCurrentPage(currentPage + 1);
};

// prevent loading molecules multiple times
const firstLoadRef = useRef(!firstLoad);

useEffect(() => {
// TODO this reloads too much..
loadFromServer({
url: getUrl({ list_type, target_on, mol_group_on }),
setOldUrl: url => setOldUrl(url),
old_url: oldUrl.current,
list_type,
setObjectList: setMoleculeList,
setCachedMolLists,
mol_group_on,
cached_mol_lists
})
.then(() => {
console.log('initializing filter');
setPredefinedFilter(dispatch(initializeFilter()).predefined);
// initialize molecules on first target load
if (
stage &&
cached_mol_lists &&
cached_mol_lists[mol_group_on] &&
firstLoadRef &&
firstLoadRef.current &&
hideProjects &&
target !== undefined
) {
console.log('initializing molecules');
firstLoadRef.current = false;
dispatch(setFirstLoad(false));
dispatch(initializeMolecules(stage, cached_mol_lists[mol_group_on].results));
}
})
.catch(error => {
throw new Error(error);
});
}, [
list_type,
mol_group_on,
setMoleculeList,
stage,
firstLoad,
target_on,
setCachedMolLists,
cached_mol_lists,
dispatch,
hideProjects,
target
]);

const listItemOffset = (currentPage + 1) * moleculesPerPage;
const currentMolecules = joinedMoleculeLists.slice(0, listItemOffset);
// setCurrentMolecules(currentMolecules);
Expand Down

0 comments on commit 91ea286

Please sign in to comment.