Skip to content

Commit

Permalink
refact: rename fetchDatasetSummaries... action
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Oct 29, 2024
1 parent 1ae658a commit ddfea7d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/datasets/Dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
deleteDatasetLinkedFieldSetIfPossible,
} from "@/modules/metadata/actions";

import { fetchDatasetDataTypesIfPossible, fetchDatasetSummariesIfPossible } from "@/modules/datasets/actions";
import { fetchDatasetDataTypesIfPossible, fetchDatasetSummariesIfNeeded } from "@/modules/datasets/actions";

import { INITIAL_DATA_USE_VALUE } from "@/duo";
import { simpleDeepCopy, nop } from "@/utils/misc";
Expand Down Expand Up @@ -335,7 +335,7 @@ const mapDispatchToProps = (dispatch, ownProps) => ({
deleteProjectDataset: (dataset) => dispatch(deleteProjectDatasetIfPossible(ownProps.project, dataset)),
deleteLinkedFieldSet: (dataset, linkedFieldSet, linkedFieldSetIndex) =>
dispatch(deleteDatasetLinkedFieldSetIfPossible(dataset, linkedFieldSet, linkedFieldSetIndex)),
fetchDatasetSummary: (datasetId) => dispatch(fetchDatasetSummariesIfPossible(datasetId)),
fetchDatasetSummary: (datasetId) => dispatch(fetchDatasetSummariesIfNeeded(datasetId)),
fetchDatasetDataTypesSummary: (datasetId) => dispatch(fetchDatasetDataTypesIfPossible(datasetId)),
});

Expand Down
2 changes: 1 addition & 1 deletion src/modules/datasets/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const fetchServiceDatasetSummary = networkAction((serviceInfo, datasetID) => ({
url: `${serviceInfo.url}/datasets/${datasetID}/summary`,
}));

export const fetchDatasetSummariesIfPossible = (datasetID) => async (dispatch, getState) => {
export const fetchDatasetSummariesIfNeeded = (datasetID) => async (dispatch, getState) => {
const existingSummaryState = getState().datasetSummaries.itemsByID[datasetID] ?? {};
if (existingSummaryState.isFetching || (!existingSummaryState.isInvalid && existingSummaryState.hasAttempted)) return;
dispatch(beginFlow(FETCHING_DATASET_SUMMARIES, { datasetID }));
Expand Down
4 changes: 2 additions & 2 deletions src/modules/datasets/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useAppDispatch, useAppSelector } from "@/store";
import {
fetchDatasetDataTypesIfPossible,
fetchDatasetsDataTypes,
fetchDatasetSummariesIfPossible,
fetchDatasetSummariesIfNeeded,
} from "@/modules/datasets/actions";

export const useDatasetDataTypes = () => {
Expand Down Expand Up @@ -50,7 +50,7 @@ export const useDatasetSummariesByID = (datasetId) => {
*/
const dispatch = useAppDispatch();
useEffect(() => {
dispatch(fetchDatasetSummariesIfPossible(datasetId)).catch(console.error);
dispatch(fetchDatasetSummariesIfNeeded(datasetId)).catch(console.error);
}, [dispatch, datasetId]);
return useAppSelector((state) => state.datasetSummaries.itemsByID[datasetId]);
};

0 comments on commit ddfea7d

Please sign in to comment.