Skip to content
Snippets Groups Projects
Verified Commit df71e8c3 authored by Dennis Collaris's avatar Dennis Collaris
Browse files

fix: backwards compatibility with old settings format preventing crash on launch

parent b5b078d1
Branches fix/sharelink
No related tags found
1 merge request!189feat(mapvis): refactor of config logic and choropleth
......@@ -7,6 +7,18 @@ import { MapProps } from '../mapvis';
import { LayerSettingsType } from '../mapvis.types';
export const MapSettings = ({ settings, graphMetadata, updateSettings }: VisualizationSettingsPropTypes<MapProps>) => {
// For backwards compatibility with older saveStates, we migrate information from settings.nodes to settings.location
// FIXME: this can be removed once all systems have updated their saveStates.
if (!('location' in settings)) {
settings = JSON.parse(JSON.stringify(settings)); // Undo Object.preventExtensions()
settings.location = Object.entries(settings.nodes)
.map(([k, v]) => [k, {
lat: (v as any).lat,
lon: (v as any).lon
}])
.reduce((obj, [k, v]) => ({...obj, [k as string]: v}), {});
}
const DataLayerSettings = settings.layer && layerSettings?.[settings.layer];
const updateLayerSettings = (updatedKeyValue: Partial<LayerSettingsType>) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment