From b5b6c4866c02717fc91e5e6f8ce4a4039c82f9fd Mon Sep 17 00:00:00 2001 From: Victor Rocheleau Date: Wed, 23 Aug 2023 16:27:19 +0000 Subject: [PATCH] variants dataset summary data in redux store --- src/modules/datasets/actions.js | 5 +++-- src/modules/datasets/reducers.js | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/modules/datasets/actions.js b/src/modules/datasets/actions.js index 2ce041cad..4a1e879f7 100644 --- a/src/modules/datasets/actions.js +++ b/src/modules/datasets/actions.js @@ -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)); }; diff --git a/src/modules/datasets/reducers.js b/src/modules/datasets/reducers.js index 5f822d30f..04be2a845 100644 --- a/src/modules/datasets/reducers.js +++ b/src/modules/datasets/reducers.js @@ -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 {