Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[fix] prevent second shadow effect (#2631)
Igor Dykhta7e3ea28b1052
diff --git a/src/reducers/src/vis-state-updaters.ts b/src/reducers/src/vis-state-updaters.tsindex b5d18856e..8e01b6f5d 100644--- a/src/reducers/src/vis-state-updaters.ts+++ b/src/reducers/src/vis-state-updaters.ts@@ -80,7 +80,8 @@ import {FILTER_VIEW_TYPES,MAX_DEFAULT_TOOLTIPS,DEFAULT_TEXT_LABEL,- COMPARE_TYPES+ COMPARE_TYPES,+ LIGHT_AND_SHADOW_EFFECT} from '@kepler.gl/constants';import {pick_,@@ -1436,6 +1437,14 @@ export const addEffectUpdater = (state: VisState,action: VisStateActions.AddEffectUpdaterAction): VisState => {+ if (+ action.config?.type === LIGHT_AND_SHADOW_EFFECT.type &&+ state.effects.some(effect => effect.type === LIGHT_AND_SHADOW_EFFECT.type)+ ) {+ Console.warn(`Can't add more than one ${LIGHT_AND_SHADOW_EFFECT.name} effect`);+ return state;+ }+const newEffect = createEffect(action.config);// collapse configurators for other effectsdiff --git a/test/node/reducers/vis-state-test.js b/test/node/reducers/vis-state-test.jsindex 3b7484efe..359371a3f 100644--- a/test/node/reducers/vis-state-test.js+++ b/test/node/reducers/vis-state-test.js@@ -30,7 +30,8 @@ import {LAYER_VIS_CONFIGS,DEFAULT_TEXT_LABEL,DEFAULT_COLOR_UI,- FILTER_VIEW_TYPES+ FILTER_VIEW_TYPES,+ LIGHT_AND_SHADOW_EFFECT} from '@kepler.gl/constants';const {ArcLayer, PointLayer, GeojsonLayer, LineLayer, TripLayer} = KeplerGlLayers;@@ -5426,13 +5427,26 @@ test('#VisStateUpdater -> addEffect', t => {nextState,VisStateActions.addEffect({id: 'e_shadow',- type: 'lightAndShadow',+ type: LIGHT_AND_SHADOW_EFFECT.type,parameters: {timestamp: 1689280466362, timezone: 'UTC'}}));t.equal(nextState.effects.length, 2, 'should add second effect');+ nextState = reducer(+ nextState,+ VisStateActions.addEffect({+ type: LIGHT_AND_SHADOW_EFFECT.type+ })+ );++ t.equal(+ nextState.effects.length,+ 2,+ `shouldn't add second ${LIGHT_AND_SHADOW_EFFECT.name} effect`+ );+const expectedEffect2 = {id: 'e_shadow',type: 'lightAndShadow',