Commit 480da7c9 authored by Matija Obreza's avatar Matija Obreza
Browse files

Datasets: Load accessionRefs after loading Dataset details

parent 31aa7603
......@@ -45,35 +45,30 @@ const receiveAccessions = (accessionRefs: Page<AccessionRef>, currentUuid: strin
payload: { accessionRefs, currentUuid },
});
function loadDataset(uuid: string) {
return (dispatch, getState) => {
return DatasetService.getDataset(uuid)
.then((dataset) => {
dispatch(receiveDataset(dataset));
})
.catch((error) => {
log('Error', error);
});
};
}
function loadMoreAccessions(uuid: string, paged?: Page<AccessionRef>) {
return (dispatch, getState) => {
return DatasetService.listAccessions(uuid, Page.nextPage(paged))
.then((paged) => {
if (paged.number === 0) {
dispatch(receiveAccessions(paged, uuid));
} else {
dispatch(appendAccessions(paged));
}
})
.catch((error) => {
log('Error', error);
});
};
}
const loadDataset = (uuid: string) => (dispatch, getState) => {
return DatasetService.getDataset(uuid)
.then((dataset) => {
dispatch(receiveDataset(dataset));
return dataset;
})
.catch((error) => {
log('Error', error);
});
};
const loadMoreAccessions = (uuid: string, paged?: Page<AccessionRef>) => (dispatch, getState) => {
return DatasetService.listAccessions(uuid, Page.nextPage(paged))
.then((paged) => {
if (paged.number === 0) {
dispatch(receiveAccessions(paged, uuid));
} else {
dispatch(appendAccessions(paged));
}
})
.catch((error) => {
log('Error', error);
});
};
const loadMoreDatasets = (paged: FilteredPage<Dataset>) => (dispatch, getState) => {
return DatasetService.datasetList(paged ? paged.filterCode : '', Page.nextPage(paged))
......
......@@ -44,15 +44,13 @@ const styles = (theme) => ({
class DatasetDetail extends React.Component<IDatasetDetailProps, any> {
protected static needs = [
({ params: { uuid } }) => loadDataset(uuid),
({ params: { uuid } }) => loadMoreAccessions(uuid),
({ params: { uuid } }) => (dispatch) => dispatch(loadDataset(uuid)).then((dataset) => loadMoreAccessions(dataset.uuid)),
];
public componentWillMount() {
const { dataset, loadDataset, loadMoreAccessions, uuid } = this.props;
loadMoreAccessions(uuid);
if (!dataset || dataset.uuid !== uuid) {
loadDataset(uuid);
loadDataset(uuid).then((dataset) => loadMoreAccessions(dataset.uuid));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment