Skip to content

Commit

Permalink
variants dataset summary data in redux store
Browse files Browse the repository at this point in the history
  • Loading branch information
v-rocheleau committed Aug 23, 2023
1 parent 2b91620 commit b5b6c48
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/modules/datasets/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const fetchDatasetSummary = networkAction((serviceInfo, datasetID) => ({
url: `${serviceInfo.url}/datasets/${datasetID}/summary`,
}));

export const fetchDatasetSummaryIfPossible = (datasetID) => (dispatch, getState) => {
export const fetchDatasetSummaryIfPossible = (datasetID) => async (dispatch, getState) => {
if (getState().datasetSummaries.isFetching) return;
return dispatch(fetchDatasetSummary(getState().services.itemsByArtifact.metadata, datasetID));
await dispatch(fetchDatasetSummary(getState().services.itemsByArtifact.metadata, datasetID));
await dispatch(fetchDatasetSummary(getState().services.itemsByArtifact.gohan, datasetID));
};
19 changes: 16 additions & 3 deletions src/modules/datasets/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,32 @@ export const datasetSummaries = (
action,
) => {
switch (action.type) {
case FETCH_DATASET_SUMMARY.REQUEST:
case FETCH_DATASET_SUMMARY.REQUEST:{
const {datasetID} = action;
return {
...state,
isFetching: true,
itemsById: {
...state.itemsById,
[datasetID]: {
...(state.itemsById[datasetID] ?? {}),
},
},
};
case FETCH_DATASET_SUMMARY.RECEIVE:
}
case FETCH_DATASET_SUMMARY.RECEIVE:{
const {datasetID} = action;
return {
...state,
itemsById: {
...state.itemsById,
[action.datasetID]: action.data,
[datasetID]: {
...state.itemsById[datasetID],
...action.data,
},
},
};
}
case FETCH_DATASET_SUMMARY.FINISH:
case FETCH_DATASET_SUMMARY.ERROR:
return {
Expand Down

0 comments on commit b5b6c48

Please sign in to comment.