From fd2bb9ee0d5ccdf52bc41f2c37c4399755abe8db Mon Sep 17 00:00:00 2001 From: Jose Buitron Date: Wed, 15 May 2024 16:17:18 -0500 Subject: [PATCH] fix: Remove current data layer --- .../components/VisualizationMapLayer.js | 2 +- .../VisualizationMapRemoteSource.js | 2 +- .../components/StoryMapForm/ChapterForm.js | 3 --- .../StoryMapForm/DataLayerDialog.js | 2 +- .../components/StoryMapForm/TitleForm.js | 23 ++++++++++--------- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/sharedData/visualization/components/VisualizationMapLayer.js b/src/sharedData/visualization/components/VisualizationMapLayer.js index ea00619800..9b9e6d10f9 100644 --- a/src/sharedData/visualization/components/VisualizationMapLayer.js +++ b/src/sharedData/visualization/components/VisualizationMapLayer.js @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see https://www.gnu.org/licenses/. */ - + import React, { useCallback, useEffect, useMemo, useState } from 'react'; import bbox from '@turf/bbox'; import _ from 'lodash/fp'; diff --git a/src/sharedData/visualization/components/VisualizationMapRemoteSource.js b/src/sharedData/visualization/components/VisualizationMapRemoteSource.js index 16d215b401..970dcfd9f4 100644 --- a/src/sharedData/visualization/components/VisualizationMapRemoteSource.js +++ b/src/sharedData/visualization/components/VisualizationMapRemoteSource.js @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see https://www.gnu.org/licenses/. */ - + import { useEffect } from 'react'; import { useMap } from 'gis/components/Map'; diff --git a/src/storyMap/components/StoryMapForm/ChapterForm.js b/src/storyMap/components/StoryMapForm/ChapterForm.js index dc929bd9b9..e1e683f7ae 100644 --- a/src/storyMap/components/StoryMapForm/ChapterForm.js +++ b/src/storyMap/components/StoryMapForm/ChapterForm.js @@ -202,9 +202,6 @@ const ChapterForm = ({ theme, record }) => { const onDataLayerChange = useCallback( dataLayerConfig => { - if (!dataLayerConfig?.id) { - return; - } const baseEvents = dataLayerConfig ? LAYER_TYPES.map(name => ({ layer: `${dataLayerConfig.id}-${name}`, diff --git a/src/storyMap/components/StoryMapForm/DataLayerDialog.js b/src/storyMap/components/StoryMapForm/DataLayerDialog.js index a210840cb0..9651d6a779 100644 --- a/src/storyMap/components/StoryMapForm/DataLayerDialog.js +++ b/src/storyMap/components/StoryMapForm/DataLayerDialog.js @@ -15,7 +15,7 @@ import { useCallback, useMemo, useState } from 'react'; * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see https://www.gnu.org/licenses/. */ - + import _ from 'lodash/fp'; import { Trans, useTranslation } from 'react-i18next'; import { useSelector } from 'react-redux'; diff --git a/src/storyMap/components/StoryMapForm/TitleForm.js b/src/storyMap/components/StoryMapForm/TitleForm.js index 49786bbd0d..20bf9a5614 100644 --- a/src/storyMap/components/StoryMapForm/TitleForm.js +++ b/src/storyMap/components/StoryMapForm/TitleForm.js @@ -65,22 +65,23 @@ const TitleForm = props => { const onDataLayerChange = useCallback( dataLayerConfig => { - if (!dataLayerConfig?.id) { - return; - } - - const baseEvents = LAYER_TYPES.map(name => ({ - layer: `${dataLayerConfig.id}-${name}`, - opacity: getLayerOpacity(name, dataLayerConfig), - duration: 0, - })); + const baseEvents = dataLayerConfig + ? LAYER_TYPES.map(name => ({ + layer: `${dataLayerConfig.id}-${name}`, + opacity: getLayerOpacity(name, dataLayerConfig), + duration: 0, + })) + : []; + const onChapterEnter = baseEvents; const onChapterExit = baseEvents.map(_.set('opacity', 0)); setConfig( _.flow( - _.set(`dataLayers.${dataLayerConfig.id}`, dataLayerConfig), - _.set('titleTransition.dataLayerConfigId', dataLayerConfig.id), + dataLayerConfig + ? _.set(`dataLayers.${dataLayerConfig.id}`, dataLayerConfig) + : _.identity, + _.set('titleTransition.dataLayerConfigId', dataLayerConfig?.id), _.set('titleTransition.onChapterEnter', onChapterEnter), _.set('titleTransition.onChapterExit', onChapterExit) )