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} /> --> <!-- <HazardMarker hazard="bumpy-road" lat={51.347447} lon={7.4028181} /> -->
{#each hazards as hazard (hazard.latitude + "-" + hazard.longitude)} {#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} {/each}
</MapLibre> </MapLibre>

View File

@ -2,11 +2,17 @@
import { Marker } from "svelte-maplibre-gl"; import { Marker } from "svelte-maplibre-gl";
import { map } from "./map.svelte"; 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(); let img: HTMLImageElement | undefined = $state();
</script> </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 <Marker
lnglat={{ lnglat={{
lat: lat, lat: lat,

View File

@ -287,7 +287,10 @@
<Button <Button
variant="outline" variant="outline"
onclick={async () => { 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!"); alert("Thanks for your report!");
await fetchHazards(); await fetchHazards();
}} }}

View File

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

View File

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

View File

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