style: run prettier
All checks were successful
TrafficCue CI / check (push) Successful in 1m1s
TrafficCue CI / build (push) Successful in 1m40s
TrafficCue CI / build-android (push) Successful in 14m14s

This commit is contained in:
2025-09-19 21:54:43 +02:00
parent 93514ae5b4
commit c071b5d7a9
6 changed files with 39 additions and 16 deletions

View File

@ -183,6 +183,10 @@
<!-- <HazardMarker hazard="bumpy-road" lat={51.347447} lon={7.4028181} /> -->
{#each hazards as hazard (hazard.latitude + "-" + hazard.longitude)}
<HazardMarker hazard={hazard.type} lat={hazard.latitude} lon={hazard.longitude} />
<HazardMarker
hazard={hazard.type}
lat={hazard.latitude}
lon={hazard.longitude}
/>
{/each}
</MapLibre>

View File

@ -2,11 +2,17 @@
import { Marker } from "svelte-maplibre-gl";
import { map } from "./map.svelte";
let { hazard, lat, lon }: { hazard: string, lat: number, lon: number } = $props();
let { hazard, lat, lon }: { hazard: string; lat: number; lon: number } =
$props();
let img: HTMLImageElement | undefined = $state();
</script>
<img src="/img/hazards/{hazard}.png" alt="{hazard} Marker" bind:this={img} style="width: 32px; {map.zoom < 15 ? "display: none;" : ""}" />
<img
src="/img/hazards/{hazard}.png"
alt="{hazard} Marker"
bind:this={img}
style="width: 32px; {map.zoom < 15 ? 'display: none;' : ''}"
/>
<Marker
lnglat={{
lat: lat,

View File

@ -287,7 +287,10 @@
<Button
variant="outline"
onclick={async () => {
await postHazard({ lat: location.lat, lon: location.lng }, "bumpy-road");
await postHazard(
{ lat: location.lat, lon: location.lng },
"bumpy-road",
);
alert("Thanks for your report!");
await fetchHazards();
}}

View File

@ -4,19 +4,25 @@ import { location } from "./location.svelte";
export const hazards: Hazard[] = $state([]);
export async function fetchHazards() {
if(!location.available) return;
const newHazards = await getHazards({ lat: location.lat, lon: location.lng }, 100); // TODO: get radius from server config
if (!location.available) return;
const newHazards = await getHazards(
{ lat: location.lat, lon: location.lng },
100,
); // TODO: get radius from server config
hazards.splice(0, hazards.length, ...newHazards);
}
setInterval(() => {
fetchHazards();
}, 1000 * 60 * 5) // Every 5 minutes
setInterval(
() => {
fetchHazards();
},
1000 * 60 * 5,
); // Every 5 minutes
// TODO: get from server config
const initalFetch = setInterval(() => {
if(location.available) {
if (location.available) {
fetchHazards();
clearInterval(initalFetch);
}
})
});

View File

@ -138,7 +138,10 @@
// TODO: include partial maneuver time
if (!routing.currentTrip) return 0;
let total = 0;
for (const [index, maneuver] of routing.currentTrip.legs[0].maneuvers.entries()) {
for (const [
index,
maneuver,
] of routing.currentTrip.legs[0].maneuvers.entries()) {
if (index >= routing.currentTripInfo.maneuverIdx) {
total += maneuver.time;
}
@ -148,7 +151,7 @@
const timeLeft = $derived.by(() => {
return formatTimeLeft(getTimeLeft());
})
});
</script>
{fullDistanceText}, {timeLeft}

View File

@ -243,7 +243,8 @@ export async function getHazards(location: WorldLocation, radius = 50) {
// throw new Error("Hazards capability is not available");
// }
const res = await fetch(
LNV_SERVER + `/hazards?lat=${location.lat}&lon=${location.lon}&radius=${radius}`,
LNV_SERVER +
`/hazards?lat=${location.lat}&lon=${location.lon}&radius=${radius}`,
);
if (!res.ok) {
throw new Error(`Failed to fetch hazards: ${res.statusText}`);