Skip to content

Commit

Permalink
#107 disable auto check first cluster and molecule
Browse files Browse the repository at this point in the history
  • Loading branch information
tibor-postek-m2ms committed Feb 25, 2020
1 parent 2e90504 commit 21cb5df
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 43 deletions.
5 changes: 2 additions & 3 deletions js/components/preview/compounds/compoundView.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@ export const CompoundView = memo(({ height, width, data }) => {
const { getNglView } = useContext(NglContext);
const majorViewStage = getNglView(VIEWS.MAJOR_VIEW).stage;

const [oldUrl, setOldUrl] = useState('');
const [state, setState] = useState();

useEffect(() => {
let onCancel = () => {};
dispatch(loadCompoundImageData({ width, height, data, onCancel, oldUrl, setOldUrl })).catch(error => {
dispatch(loadCompoundImageData({ width, height, data, onCancel })).catch(error => {
setState(() => {
throw error;
});
});
return () => {
onCancel();
};
}, [height, width, data, oldUrl, dispatch]);
}, [height, width, data, dispatch]);

const not_selected_style = {
width: (width + 5).toString() + 'px',
Expand Down
4 changes: 1 addition & 3 deletions js/components/preview/compounds/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const handleClickOnCompound = ({ data, event, majorViewStage }) => async
}
};

export const loadCompoundImageData = ({ width, height, onCancel, data, oldUrl, setOldUrl }) => dispatch => {
export const loadCompoundImageData = ({ width, height, onCancel, data }) => dispatch => {
let url = undefined;
let key = undefined;

Expand All @@ -147,9 +147,7 @@ export const loadCompoundImageData = ({ width, height, onCancel, data, oldUrl, s
width,
height,
key,
old_url: oldUrl,
setImg_data: image => dispatch(updateCurrentCompound({ id: data.index, key: 'image', value: image })),
setOld_url: newUrl => setOldUrl(newUrl),
url,
cancel: onCancel
});
Expand Down
51 changes: 18 additions & 33 deletions js/components/preview/molecule/moleculeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { Panel } from '../../common/Surfaces/Panel';
import { ComputeSize } from '../../../utils/computeSize';
import { moleculeProperty } from './helperConstants';
import { setSortDialogOpen } from './redux/actions';
import { selectFirstMolecule } from './redux/dispatchActions';
import { VIEWS } from '../../../constants/constants';
import { NglContext } from '../../nglView/nglProvider';

Expand Down Expand Up @@ -108,8 +107,7 @@ const MoleculeList = memo(
getJoinedMoleculeList,
filterSettings,
sortDialogOpen,
setSortDialogOpen,
selectFirstMolecule
setSortDialogOpen
}) => {
const classes = useStyles();
const list_type = listType.MOLECULE;
Expand Down Expand Up @@ -149,35 +147,23 @@ const MoleculeList = memo(
};

useEffect(() => {
if (stage) {
loadFromServer({
url: getUrl({ list_type, target_on, mol_group_on }),
setOldUrl: url => setOldUrl(url),
old_url: oldUrl.current,
list_type,
setObjectList: moleculeList => {
setMoleculeList(moleculeList);
selectFirstMolecule(stage, moleculeList);
},
setCachedMolLists,
mol_group_on,
cached_mol_lists
}).catch(error => {
setState(() => {
throw error;
});
loadFromServer({
url: getUrl({ list_type, target_on, mol_group_on }),
setOldUrl: url => setOldUrl(url),
old_url: oldUrl.current,
list_type,
setObjectList: moleculeList => {
setMoleculeList(moleculeList);
},
setCachedMolLists,
mol_group_on,
cached_mol_lists
}).catch(error => {
setState(() => {
throw error;
});
}
}, [
list_type,
mol_group_on,
setMoleculeList,
target_on,
setCachedMolLists,
cached_mol_lists,
stage,
selectFirstMolecule
]);
});
}, [list_type, mol_group_on, setMoleculeList, target_on, setCachedMolLists, cached_mol_lists]);

const listItemOffset = (currentPage + 1) * moleculesPerPage;
const currentMolecules = joinedMoleculeLists.slice(0, listItemOffset);
Expand Down Expand Up @@ -335,8 +321,7 @@ const mapDispatchToProps = {
setCachedMolLists: apiActions.setCachedMolLists,
deleteObject,
loadObject,
setSortDialogOpen,
selectFirstMolecule
setSortDialogOpen
};
MoleculeList.displayName = 'MoleculeList';
export default connect(mapStateToProps, mapDispatchToProps)(MoleculeList);
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const loadMoleculeGroups = ({ summaryView, setOldUrl, oldUrl, onCancel, i
list_type,
setObjectList: async mol_group_list => {
await dispatch(setMolGroupList(mol_group_list));
dispatch(selectFirstMolGroup({ summaryView }));
// dispatch(selectFirstMolGroup({ summaryView }));
},
cancel: onCancel
});
Expand Down
12 changes: 9 additions & 3 deletions js/utils/genericView.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export const loadFromServer = ({ width, height, key, old_url, setImg_data, setOl
return api({ url, cancel })
.then(response => setImg_data(response.data))
.finally(() => {
setOld_url(url.toString());
if (setOld_url) {
setOld_url(url.toString());
}
});
}
} else {
Expand All @@ -23,10 +25,14 @@ export const loadFromServer = ({ width, height, key, old_url, setImg_data, setOl
}
})
.finally(() => {
setOld_url(url.toString());
if (setOld_url) {
setOld_url(url.toString());
}
});
}
}
setOld_url(url.toString());
if (setOld_url) {
setOld_url(url.toString());
}
return Promise.resolve();
};

0 comments on commit 21cb5df

Please sign in to comment.