Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/#424'
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed Oct 19, 2020
2 parents e5181c4 + 869dc70 commit cbee039
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
7 changes: 4 additions & 3 deletions js/components/preview/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const Preview = memo(({ isStateLoaded, hideProjects }) => {

const [molGroupsHeight, setMolGroupsHeight] = useState(0);
const [filterItemsHeight, setFilterItemsHeight] = useState(0);
const [filterItemsHeightDataset, setFilterItemsHeightDataset] = useState(0);

/* Hit navigator list height */
const moleculeListHeight = `calc(100vh - ${headerHeight}px - ${theme.spacing(2)}px - ${molGroupsHeight}px - ${
Expand All @@ -128,7 +129,7 @@ const Preview = memo(({ isStateLoaded, hideProjects }) => {
/* Custom dataset list height */
const customMoleculeListHeight = `calc(100vh - ${headerHeight}px - ${theme.spacing(hideProjects ? 1 : 2)}px - ${
hideProjects ? 0 : molGroupsHeight
}px - ${filterItemsHeight > 0 ? filterItemsHeight + theme.spacing(1) / 2 : 0}px - ${theme.spacing(
}px - ${filterItemsHeightDataset > 0 ? filterItemsHeightDataset + theme.spacing(1) / 2 : 0}px - ${theme.spacing(
8
)}px - ${TABS_HEADER_HEIGHT}px)`;

Expand Down Expand Up @@ -260,8 +261,8 @@ const Preview = memo(({ isStateLoaded, hideProjects }) => {
<CustomDatasetList
dataset={dataset}
height={customMoleculeListHeight}
setFilterItemsHeight={setFilterItemsHeight}
filterItemsHeight={filterItemsHeight}
setFilterItemsHeight={setFilterItemsHeightDataset}
filterItemsHeight={filterItemsHeightDataset}
hideProjects={hideProjects}
isActive={index === selectedDatasetIndex}
/>
Expand Down
13 changes: 8 additions & 5 deletions js/components/preview/molecule/moleculeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import * as listType from '../../../constants/listTypes';
import { useRouteMatch } from 'react-router-dom';
import { setSortDialogOpen } from './redux/actions';
import { setCachedMolLists, setMoleculeList } from '../../../reducers/api/actions';
import { DatasetMoleculeView } from '../../datasets/datasetMoleculeView';
import { AlertModal } from '../../common/Modal/AlertModal';

const useStyles = makeStyles(theme => ({
Expand Down Expand Up @@ -292,6 +291,12 @@ export const MoleculeList = memo(({ height, setFilterItemsHeight, filterItemsHei
const canLoadMore = listItemOffset < joinedMoleculeLists.length;

const wereMoleculesInitialized = useRef(false);
const firstInitializationMolecule = useRef(null);

let first = joinedMoleculeLists && joinedMoleculeLists[0];
if (wereMoleculesInitialized.current === false && first) {
firstInitializationMolecule.current = first;
}

useEffect(() => {
if (proteinsHasLoaded === true || proteinsHasLoaded === null) {
Expand Down Expand Up @@ -320,8 +325,7 @@ export const MoleculeList = memo(({ height, setFilterItemsHeight, filterItemsHei
wereMoleculesInitialized.current === false
) {
let moleculeList = cached_mol_lists[mol_group_on];
let firstId = joinedMoleculeLists && joinedMoleculeLists[0] && joinedMoleculeLists[0].id;
dispatch(initializeMolecules(stage, moleculeList, firstId));
dispatch(initializeMolecules(stage, moleculeList, firstInitializationMolecule.current));
wereMoleculesInitialized.current = true;
}
})
Expand All @@ -339,8 +343,7 @@ export const MoleculeList = memo(({ height, setFilterItemsHeight, filterItemsHei
dispatch,
hideProjects,
target,
proteinsHasLoaded,
joinedMoleculeLists
proteinsHasLoaded
]);

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions js/components/preview/molecule/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ export const removeLigand = (stage, data) => dispatch => {
* Turn on the complex of the first ligand of the site
* Turn on every ligand of the site
*/
export const initializeMolecules = (majorView, moleculeList, firstId) => dispatch => {
export const initializeMolecules = (majorView, moleculeList, first) => dispatch => {
if (moleculeList && majorView) {
const firstMolecule = moleculeList.find(m => m.id === firstId) || moleculeList[0];
const firstMolecule = first || moleculeList[0];
if (firstMolecule) {
dispatch(addHitProtein(majorView, firstMolecule, colourList[firstMolecule.id % colourList.length]));
dispatch(addLigand(majorView, firstMolecule, colourList[firstMolecule.id % colourList.length], true));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fragalysis-frontend",
"version": "0.9.2",
"version": "0.9.5",
"description": "Frontend for fragalysis",
"main": "webpack.config.js",
"scripts": {
Expand Down

0 comments on commit cbee039

Please sign in to comment.