Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Bug] Fix composer types, schema types (#2208)

Igor Dykhtae5686fdaaa76
diff --git a/src/components/src/side-panel/layer-panel/layer-list.tsx b/src/components/src/side-panel/layer-panel/layer-list.tsx
index 2b2b28b29..fff4c4974 100644
--- a/src/components/src/side-panel/layer-panel/layer-list.tsx
+++ b/src/components/src/side-panel/layer-panel/layer-list.tsx
@@ -132,7 +132,7 @@ function LayerListFactory(LayerPanel: ReturnType<typeof LayerPanelFactory>) {
const layersToShow = useMemo(() => {
return layerOrder.reduce((acc, layerId) => {
- const layer = findById<Layer>(layerId)(layers);
+ const layer = findById(layerId)(layers);
if (!layer) {
return acc;
}
diff --git a/src/layers/src/mapbox-utils.ts b/src/layers/src/mapbox-utils.ts
index 1f6584b71..1010576da 100644
--- a/src/layers/src/mapbox-utils.ts
+++ b/src/layers/src/mapbox-utils.ts
@@ -42,7 +42,7 @@ export function generateMapboxLayers(
.slice()
.reverse()
.filter(layerId => {
- const layer = findById<Layer>(layerId)(layers);
+ const layer = findById(layerId)(layers);
return layer?.overlayType === OVERLAY_TYPE_CONST.mapboxgl && layersToRender[layerId];
})
.reduce((acc, layerId) => {
diff --git a/src/reducers/src/composer-helpers.ts b/src/reducers/src/composer-helpers.ts
index 0fbda7975..0ceff207a 100644
--- a/src/reducers/src/composer-helpers.ts
+++ b/src/reducers/src/composer-helpers.ts
@@ -38,9 +38,8 @@ export function apply_<State, P>(
return state => updater(state, payload);
}
-export function with_<State>(
- fn: (state: State) => (nextState: State) => State
-): (state: State) => State {
+type Arg<State> = (state: State) => (nextState: State) => State;
+export function with_<State>(fn: Arg<State>): (state: State) => State {
return state => fn(state)(state);
}
diff --git a/src/schemas/src/vis-state-schema.ts b/src/schemas/src/vis-state-schema.ts
index 2628b6b4f..bfc42af34 100644
--- a/src/schemas/src/vis-state-schema.ts
+++ b/src/schemas/src/vis-state-schema.ts
@@ -573,7 +573,7 @@ export class LayerSchemaV0 extends Schema {
return {
[this.key as 'layers']: visState.layerOrder.reduce((saved, layerId) => {
// save layers according to their rendering order
- const layer = findById<Layer>(layerId)(layers);
+ const layer = findById(layerId)(layers);
if (layer?.isValidToSave()) {
saved.push(this.savePropertiesOrApplySchema(layer).layers);
}
diff --git a/src/utils/src/utils.ts b/src/utils/src/utils.ts
index 755cdd30b..dc788f5bd 100644
--- a/src/utils/src/utils.ts
+++ b/src/utils/src/utils.ts
@@ -212,17 +212,17 @@ export function isFunction(func) {
return typeof func === 'function';
}
-export function findById<X extends {id: string}>(id: string): (arr: X[]) => X | undefined {
+export function findById(id: string): <X extends {id: string}>(arr: X[]) => X | undefined {
return arr => arr.find(a => a.id === id);
}
/**
* Returns array difference from
*/
-export function arrayDifference<X extends {id: string}>(origin: X[]): (compare: X[]) => X[] {
+export function arrayDifference<X extends {id: string}>(source: X[]): (compare: X[]) => X[] {
return compare =>
- origin.reduce((acc, element) => {
- const foundElement = findById<X>(element.id)(compare);
+ source.reduce((acc, element) => {
+ const foundElement = findById(element.id)(compare);
return foundElement ? [...acc, foundElement] : acc;
}, [] as X[]);
}