Fix: better error handling and handling of changes

This commit is contained in:
Pieter Vander Vennet 2023-05-01 01:14:48 +02:00
parent 7b73578f88
commit 7813653265
8 changed files with 36 additions and 10 deletions

View file

@ -164,7 +164,11 @@ export default class MetaTagging {
}
if (somethingChanged) {
featurePropertiesStores?.getStore(feature.properties.id)?.ping()
try {
featurePropertiesStores?.getStore(feature.properties.id)?.ping()
} catch (e) {
console.error("Could not ping a store for a changed property due to", e)
}
atLeastOneFeatureChanged = true
}
}

View file

@ -15,7 +15,6 @@ import BaseUIElement from "../BaseUIElement"
import Img from "../Base/Img"
import Title from "../Base/Title"
import { CheckBox } from "../Input/Checkboxes"
import Minimap from "../Base/Minimap"
import SearchAndGo from "./SearchAndGo"
import Toggle from "../Input/Toggle"
import List from "../Base/List"

View file

@ -72,6 +72,9 @@
}
Stores.Chronic(50).addCallback(_ => stabilize());
floors.addCallback(floors => {
forceIndex = floors.findIndex(s => s === value.data)
})
let image: HTMLImageElement;
$:{

View file

@ -50,7 +50,7 @@
let layerIsDisplayed: UIEventSource<boolean> | undefined = undefined;
let layerHasFilters: Store<boolean> | undefined = undefined;
let globalFilter: UIEventSource<GlobalFilter[]> = state.layerState.globalFilters;
let _globalFilter: GlobalFilter[];
let _globalFilter: GlobalFilter[] = [];
onDestroy(globalFilter.addCallbackAndRun(globalFilter => {
console.log("Global filters are", globalFilter);
_globalFilter = globalFilter ?? [];
@ -85,7 +85,7 @@
creating = true;
const location: { lon: number; lat: number } = preciseCoordinate.data;
const snapTo: WayId | undefined = <WayId>snappedToObject.data;
const tags: Tag[] = selectedPreset.preset.tags.concat(..._globalFilter.map(f => f.onNewPoint.tags));
const tags: Tag[] = selectedPreset.preset.tags.concat(..._globalFilter.map(f => f?.onNewPoint?.tags ?? []));
console.log("Creating new point at", location, "snapped to", snapTo, "with tags", tags);
let snapToWay: undefined | OsmWay = undefined;
@ -249,7 +249,7 @@
<Tr t={t.backToSelect} />
</div>
</SubtleButton>
{:else if _globalFilter.length > checkedOfGlobalFilters}
{:else if _globalFilter?.length > 0 && _globalFilter?.length > checkedOfGlobalFilters}
<Tr t={_globalFilter[checkedOfGlobalFilters].onNewPoint?.safetyCheck} />
<SubtleButton on:click={() => {checkedOfGlobalFilters = checkedOfGlobalFilters + 1}}>
<img slot="image" src={_globalFilter[checkedOfGlobalFilters].onNewPoint?.icon ?? "./assets/svg/confirm.svg"} class="w-12 h-12">

View file

@ -61,6 +61,7 @@ export default class TagApplyButton implements AutoAction, SpecialVisualization
if (kv.length == 2) {
tgsSpec.push(<[string, string]>kv)
} else if (kv.length < 2) {
console.error("Invalid key spec: no '=' found in " + spec)
throw "Invalid key spec: no '=' found in " + spec
} else {
throw "Invalid key spec: multiple '=' found in " + spec

View file

@ -11,6 +11,7 @@
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig";
import WeblateLink from "../../Base/WeblateLink.svelte";
import FromHtml from "../../Base/FromHtml.svelte";
import BaseUIElement from "../../BaseUIElement";
/**
* The 'specialTranslation' renders a `Translation`-object, but interprets the special values as well
@ -27,10 +28,26 @@
}));
let specs: RenderingSpecification[] = [];
$: {
if (txt !== undefined) {
specs = SpecialVisualizations.constructSpecification(txt);
try {
if (txt !== undefined) {
specs = SpecialVisualizations.constructSpecification(txt);
}
} catch (e) {
console.error("Could not construct a specification and with arguments", txt);
}
}
function createVisualisation(specpart: Exclude<RenderingSpecification, string>): BaseUIElement {
{
try {
return specpart.func.constr(state, tags, specpart.args, feature, layer);
} catch (e) {
console.error("Could not construct a special visualisation with specification", specpart, "and tags", tags);
}
}
}
</script>
{#each specs as specpart}
@ -40,6 +57,6 @@
<WeblateLink context={t.context} />
</span>
{:else if $tags !== undefined }
<ToSvelte construct={specpart.func.constr(state, tags, specpart.args, feature, layer)}></ToSvelte>
<ToSvelte construct={createVisualisation(specpart)}></ToSvelte>
{/if}
{/each}

View file

@ -22,7 +22,9 @@
}
export let layer: LayerConfig;
let trs: { then: Translation; icon?: string; iconClass?: string }[];
$: trs = Utils.NoNull(config?.GetRenderValues(_tags));
$:{
trs = Utils.NoNull(config?.GetRenderValues(_tags));
}
let classes = ""
$:classes = config?.classes?.join(" ") ?? "";
</script>

View file

@ -121,7 +121,7 @@
</If>
</div>
<If condition={selectedViewElement.map(v => v !== undefined)}>
<If condition={selectedViewElement.map(v => v !== undefined && selectedLayer.data !== undefined,[ selectedLayer] )}>
<ModalRight on:close={() => {selectedElement.setData(undefined)}}>
<ToSvelte construct={new VariableUiElement(selectedViewElement)}></ToSvelte>
</ModalRight>