diff --git a/app/layout/project/sidebar/scenario/grid-setup/features/targets/list/component.tsx b/app/layout/project/sidebar/scenario/grid-setup/features/targets/list/component.tsx index 7d8488a63d..7a8e7b1129 100644 --- a/app/layout/project/sidebar/scenario/grid-setup/features/targets/list/component.tsx +++ b/app/layout/project/sidebar/scenario/grid-setup/features/targets/list/component.tsx @@ -191,6 +191,7 @@ export const ScenariosFeaturesTargets = ({ onGoBack }: { onGoBack: () => void }) { onSuccess: async () => { await queryClient.invalidateQueries(['selected-features', sid]); + await queryClient.invalidateQueries(['pre-gap-analysis', sid]); }, onSettled: () => { setSubmitting(false); diff --git a/app/layout/scenarios/edit/map/legend/hooks/index.ts b/app/layout/scenarios/edit/map/legend/hooks/index.ts index 3c8fc7446b..c7768a6e5c 100644 --- a/app/layout/scenarios/edit/map/legend/hooks/index.ts +++ b/app/layout/scenarios/edit/map/legend/hooks/index.ts @@ -9,7 +9,7 @@ import { orderBy, sortBy } from 'lodash'; import { useProjectCostSurfaces } from 'hooks/cost-surface'; import { useAllFeatures, useSelectedFeatures } from 'hooks/features'; -import { useAllGapAnalysis } from 'hooks/gap-analysis'; +import { useAllGapAnalysis, usePreGapAnalysis } from 'hooks/gap-analysis'; import { LEGEND_LAYERS } from 'hooks/map/constants'; import { useProject } from 'hooks/projects'; import { useScenario } from 'hooks/scenarios'; @@ -378,16 +378,7 @@ export const useGapAnalysisLegend = () => { (state) => state[`/scenarios/${sid}/edit`] ); - const gapAnalysisQuery = useAllGapAnalysis(sid, { - select: (data) => - sortBy( - data.map(({ id, featureClassName }) => ({ - id, - name: featureClassName, - })), - ['name'] - ), - }); + const gapAnalysisQuery = usePreGapAnalysis(sid, {}); return LEGEND_LAYERS['gap-analysis']({ items: gapAnalysisQuery.data,