Skip to content

Commit

Permalink
fix: Remove current data layer
Browse files Browse the repository at this point in the history
  • Loading branch information
josebui committed May 15, 2024
1 parent 0fe8e08 commit fd2bb9e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 0 additions & 3 deletions src/storyMap/components/StoryMapForm/ChapterForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down
2 changes: 1 addition & 1 deletion src/storyMap/components/StoryMapForm/DataLayerDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
23 changes: 12 additions & 11 deletions src/storyMap/components/StoryMapForm/TitleForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down

0 comments on commit fd2bb9e

Please sign in to comment.