fix: broken value display for coords in LocationSelect
All checks were successful
TrafficCue CI / check (push) Successful in 1m0s
TrafficCue CI / build (push) Successful in 1m44s
TrafficCue CI / build-android (push) Successful in 15m37s

This commit is contained in:
Cfp
2025-09-16 10:09:38 +02:00
parent 32448cb2a8
commit 59abca036e

View File

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