fix: broken value display for coords in LocationSelect
Some checks failed
TrafficCue CI / check (push) Has been cancelled
TrafficCue CI / build (push) Has been cancelled
TrafficCue CI / build-android (push) Has been cancelled

This commit is contained in:
2025-09-16 18:23:48 +02:00
parent 32448cb2a8
commit e45fd8092a

View File

@ -53,21 +53,26 @@
async function getCoordLabel(value: `${number},${number}`) { async function getCoordLabel(value: `${number},${number}`) {
const splitter = value.split(","); const splitter = value.split(",");
console.log(`getCoordLabel(${value})`);
const res = await reverseGeocode({ const res = await reverseGeocode({
lat: parseFloat(splitter[0]), lat: parseFloat(splitter[0]),
lon: parseFloat(splitter[1]), lon: parseFloat(splitter[1]),
}); });
if (res.length == 0) return "<unknown>"; if (res.length == 0) return "<unknown>";
const feature = res[0]; const feature = res[0];
console.log(`getCoordLabel(${value}) == ${feature.properties.name}`);
return feature.properties.name; return feature.properties.name;
} }
const selectedValue = $derived( const selectedValue = $derived(
new Promise((r) => { new Promise((r) => {
r( if (locations.find((f) => f.value === value)) {
locations.find((f) => f.value === value)?.label || return r(locations.find((f) => f.value === value)?.label);
getCoordLabel(value).then((v) => r(v)), }
); getCoordLabel(value).then((v) => r(v));
}).then((label) => {
console.log("[LocationSelect] selectedValue", { value, label });
return label;
}), }),
); );