diff --git a/frontend/src/features/Dashboard/components/Layers/ActiveDashboardLayer.tsx b/frontend/src/features/Dashboard/components/Layers/ActiveDashboardLayer.tsx index 9dcee4c92..da3e1361a 100644 --- a/frontend/src/features/Dashboard/components/Layers/ActiveDashboardLayer.tsx +++ b/frontend/src/features/Dashboard/components/Layers/ActiveDashboardLayer.tsx @@ -32,10 +32,12 @@ export function ActiveDashboardLayer({ map }: BaseMapChildrenProps) { const activeDashboardId = useAppSelector(state => state.dashboard.activeDashboardId) const dashboard = useAppSelector(state => getDashboardById(state.dashboard, activeDashboardId)) - const { data: reportings } = useGetReportingsByIdsQuery(dashboard?.dashboard.reportingIds ?? []) - const { data: regulatoryLayers } = useGetRegulatoryLayersQuery() - const { data: ampLayers } = useGetAMPsQuery() - const { data: vigilanceAreas } = useGetVigilanceAreasQuery() + const { data: reportings } = useGetReportingsByIdsQuery(dashboard?.dashboard.reportingIds ?? [], { + skip: !dashboard + }) + const { data: regulatoryLayers } = useGetRegulatoryLayersQuery(undefined, { skip: !dashboard }) + const { data: ampLayers } = useGetAMPsQuery(undefined, { skip: !dashboard }) + const { data: vigilanceAreas } = useGetVigilanceAreasQuery(undefined, { skip: !dashboard }) const openPanel = dashboard?.openPanel const activeDashboard = dashboard?.dashboard diff --git a/frontend/src/features/Dashboard/components/Layers/PreviewDashboardLayer.tsx b/frontend/src/features/Dashboard/components/Layers/PreviewDashboardLayer.tsx index 31b345966..f5440093a 100644 --- a/frontend/src/features/Dashboard/components/Layers/PreviewDashboardLayer.tsx +++ b/frontend/src/features/Dashboard/components/Layers/PreviewDashboardLayer.tsx @@ -40,9 +40,9 @@ export function DashboardPreviewLayer({ map }: BaseMapChildrenProps) { }, [openPanel] ) - const { data: regulatoryLayers } = useGetRegulatoryLayersQuery() - const { data: ampLayers } = useGetAMPsQuery() - const { data: vigilanceAreas } = useGetVigilanceAreasQuery() + const { data: regulatoryLayers } = useGetRegulatoryLayersQuery(undefined, { skip: !dashboard }) + const { data: ampLayers } = useGetAMPsQuery(undefined, { skip: !dashboard }) + const { data: vigilanceAreas } = useGetVigilanceAreasQuery(undefined, { skip: !dashboard }) const previewLayersVectorSourceRef = useRef(new VectorSource()) as React.MutableRefObject< VectorSource>