From 5c9f53a5c457b60890258e64c1fd4e956cb793cf Mon Sep 17 00:00:00 2001 From: Maxime Perrault Date: Tue, 17 Sep 2024 16:13:33 +0200 Subject: [PATCH] tech: fix identity warning from redux --- frontend/src/api/regulatoryLayersAPI.ts | 13 ++++++++----- frontend/src/domain/shared_slices/Regulatory.ts | 9 +-------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/frontend/src/api/regulatoryLayersAPI.ts b/frontend/src/api/regulatoryLayersAPI.ts index 9265b4e2f..97eaa2ac8 100644 --- a/frontend/src/api/regulatoryLayersAPI.ts +++ b/frontend/src/api/regulatoryLayersAPI.ts @@ -5,14 +5,14 @@ import { boundingExtent, createEmpty } from 'ol/extent' import { createCachedSelector } from 're-reselect' import { monitorenvPrivateApi } from './api' -import { getSelectedRegulatoryLayerIds } from '../domain/shared_slices/Regulatory' import type { - RegulatoryLayerWithMetadata, - RegulatoryLayerWithMetadataFromAPI, RegulatoryLayerCompact, - RegulatoryLayerCompactFromAPI + RegulatoryLayerCompactFromAPI, + RegulatoryLayerWithMetadata, + RegulatoryLayerWithMetadataFromAPI } from '../domain/entities/regulatory' +import type { HomeRootState } from '@store/index' import type { Coordinate } from 'ol/coordinate' const GET_REGULATORY_LAYER_ERROR_MESSAGE = "Nous n'avons pas pu récupérer la zones réglementaire" @@ -58,7 +58,10 @@ export const regulatoryLayersAPI = monitorenvPrivateApi.injectEndpoints({ export const { useGetRegulatoryLayerByIdQuery, useGetRegulatoryLayersQuery } = regulatoryLayersAPI export const getSelectedRegulatoryLayers = createSelector( - [regulatoryLayersAPI.endpoints.getRegulatoryLayers.select(), getSelectedRegulatoryLayerIds], + [ + regulatoryLayersAPI.endpoints.getRegulatoryLayers.select(), + (state: HomeRootState) => state.regulatory.selectedRegulatoryLayerIds + ], (regulatoryLayers, selectedRegulatoryLayerIds) => { const emptyArray = [] diff --git a/frontend/src/domain/shared_slices/Regulatory.ts b/frontend/src/domain/shared_slices/Regulatory.ts index 31c4cca0c..222939496 100644 --- a/frontend/src/domain/shared_slices/Regulatory.ts +++ b/frontend/src/domain/shared_slices/Regulatory.ts @@ -1,10 +1,8 @@ -import { createSelector, createSlice, type PayloadAction } from '@reduxjs/toolkit' +import { createSlice, type PayloadAction } from '@reduxjs/toolkit' import _ from 'lodash' import { persistReducer } from 'redux-persist' import storage from 'redux-persist/lib/storage' -import type { HomeRootState } from '../../store' - const persistConfig = { key: 'regulatory', storage, @@ -81,8 +79,3 @@ export const { } = regulatorySlice.actions export const regulatorySlicePersistedReducer = persistReducer(persistConfig, regulatorySlice.reducer) - -export const getSelectedRegulatoryLayerIds = createSelector( - [(state: HomeRootState) => state.regulatory.selectedRegulatoryLayerIds], - selectedRegulatoryLayerIds => selectedRegulatoryLayerIds -)