style: run prettier
All checks were successful
TrafficCue CI / check (push) Successful in 1m31s
TrafficCue CI / build (push) Successful in 9m49s
TrafficCue CI / build-android (push) Successful in 23m30s

This commit is contained in:
2025-10-03 19:54:14 +02:00
parent de06d09d1c
commit 639b2c1aeb
13 changed files with 108 additions and 65 deletions

View File

@ -7,8 +7,11 @@
let marker: HTMLImageElement | undefined = $state();
</script>
<img
src={map.zoom > 9 ? `/img/saved/${MAP_ICONS[store.icon ?? "small.png"]}` : "/img/saved/small.png"}
src={map.zoom > 9
? `/img/saved/${MAP_ICONS[store.icon ?? "small.png"]}`
: "/img/saved/small.png"}
alt="Work Marker"
bind:this={marker}
style="width: 32px;"

View File

@ -60,7 +60,9 @@
{#each vehicles.current as vehicle (vehicle.name)}
<div class="flex items-center gap-2">
<Button
variant={selectedVehicle()?.data === vehicle.data ? "default" : "secondary"}
variant={selectedVehicle()?.data === vehicle.data
? "default"
: "secondary"}
class="w-[calc(100%-48px-8px)] p-5"
onclick={() => {
selectVehicle(vehicle.data);
@ -71,10 +73,19 @@
<Icon />
{vehicle.data.name}
</Button>
<Button variant="destructive" class="w-[48px]" onclick={() => {
if(!confirm("Are you sure you want to delete this vehicle? This action cannot be undone.")) return;
updateStore({ type: "vehicle", name: vehicle.name }, null);
}}>
<Button
variant="destructive"
class="w-[48px]"
onclick={() => {
if (
!confirm(
"Are you sure you want to delete this vehicle? This action cannot be undone.",
)
)
return;
updateStore({ type: "vehicle", name: vehicle.name }, null);
}}
>
<XIcon />
</Button>
</div>

View File

@ -20,7 +20,7 @@ export const location = $state({
center: [location.lng, location.lat],
zoom: 16,
duration: 1000,
bearing: location.heading != null ? location.heading : 0
bearing: location.heading != null ? location.heading : 0,
},
{
reason: "location",
@ -53,7 +53,7 @@ export function watchLocation() {
center: [location.lng, location.lat],
zoom: 16,
duration: 1000,
bearing: location.heading != null ? location.heading : 0
bearing: location.heading != null ? location.heading : 0,
},
{
reason: "location",

View File

@ -11,16 +11,17 @@
const locations = stores<Location>("location");
function getName(name: string) {
if(name == "home") {
if (name == "home") {
return m["saved.home"]();
} else if(name == "work") {
} else if (name == "work") {
return m["saved.work"]();
} else if(name == "school") {
} else if (name == "school") {
return m["saved.school"]();
}
return name;
}
</script>
<div
id="saved"
class="mt-2 mb-2"
@ -38,7 +39,8 @@
center: [lng, lat],
zoom: 19,
});
}}>
}}
>
{@const Icon = ICONS[location.data.icon ?? "pin"] ?? MapPinIcon}
<Icon />
{getName(location.data.name)}

View File

@ -185,12 +185,15 @@
<Button
variant="outline"
onclick={() => {
updateStore({ name: "home", type: "location" }, {
lat,
lng,
name: "home",
icon: "home"
})
updateStore(
{ name: "home", type: "location" },
{
lat,
lng,
name: "home",
icon: "home",
},
);
}}
>
<HomeIcon />
@ -199,12 +202,15 @@
<Button
variant="outline"
onclick={() => {
updateStore({ name: "school", type: "location" }, {
lat,
lng,
name: "school",
icon: "school"
})
updateStore(
{ name: "school", type: "location" },
{
lat,
lng,
name: "school",
icon: "school",
},
);
}}
>
<SchoolIcon />
@ -213,12 +219,15 @@
<Button
variant="outline"
onclick={() => {
updateStore({ name: "work", type: "location" }, {
lat,
lng,
name: "work",
icon: "work"
})
updateStore(
{ name: "work", type: "location" },
{
lat,
lng,
name: "work",
icon: "work",
},
);
}}
>
<BriefcaseIcon />

View File

@ -1,9 +1,5 @@
<script lang="ts">
import {
DownloadIcon,
FuelIcon,
ParkingSquareIcon,
} from "@lucide/svelte";
import { DownloadIcon, FuelIcon, ParkingSquareIcon } from "@lucide/svelte";
import { Button } from "../../ui/button";
import VehicleSelector from "../VehicleSelector.svelte";
import Post from "../Post.svelte";

View File

@ -89,10 +89,10 @@
lat: parseFloat(toLocation.split(",")[0]),
lon: parseFloat(toLocation.split(",")[1]),
};
const req = createValhallaRequest(selectedVehicle()?.data ?? DefaultVehicle, [
FROM,
TO,
]);
const req = createValhallaRequest(
selectedVehicle()?.data ?? DefaultVehicle,
[FROM, TO],
);
const res = await fetchRoute(ROUTING_SERVER, req);
routes = [res.trip];
if (res.alternates) {

View File

@ -5,7 +5,13 @@
import { getAuthURL, getOIDCUser } from "$lib/services/oidc";
import * as Avatar from "$lib/components/ui/avatar";
import { m } from "$lang/messages";
import { fetchMyUser, followUser, refreshToken, unfollowUser, uploadID } from "$lib/services/lnv";
import {
fetchMyUser,
followUser,
refreshToken,
unfollowUser,
uploadID,
} from "$lib/services/lnv";
interface OIDCUser {
sub: string;
@ -84,13 +90,17 @@
<span><b>Hazards:</b> {u.hazardsCount}</span>
{/await}
<input type="text" bind:value={testInput}>
<button onclick={async () => {
alert(await followUser(testInput).catch(alert));
}}>Follow</button>
<button onclick={async () => {
alert(await unfollowUser(testInput).catch(alert));
}}>Unfollow</button>
<input type="text" bind:value={testInput} />
<button
onclick={async () => {
alert(await followUser(testInput).catch(alert));
}}>Follow</button
>
<button
onclick={async () => {
alert(await unfollowUser(testInput).catch(alert));
}}>Unfollow</button
>
<pre>{user.sub}</pre>
{JSON.stringify(user, null, 2)}

View File

@ -1,6 +1,12 @@
import type { Component } from "svelte";
import { reverseGeocode } from "./services/Search";
import { BriefcaseIcon, HomeIcon, MapPinIcon, SchoolIcon, type IconProps } from "@lucide/svelte";
import {
BriefcaseIcon,
HomeIcon,
MapPinIcon,
SchoolIcon,
type IconProps,
} from "@lucide/svelte";
/**
* @deprecated Use stores instead.
@ -34,13 +40,13 @@ export const ICONS: Record<string, Component<IconProps>> = {
home: HomeIcon,
work: BriefcaseIcon,
school: SchoolIcon,
pin: MapPinIcon
pin: MapPinIcon,
};
export const MAP_ICONS: Record<string, string> = {
home: "home.png",
school: "school.png",
work: "work.png"
work: "work.png",
}; // TODO: add generic pin icon
export interface Location {

View File

@ -16,8 +16,8 @@ export async function initTTS() {
}
export function findLocaleForValhallaLanguage(language: string) {
for(const locale of locales) {
if(m["language.valhalla"]({ language }, { locale }) === language) {
for (const locale of locales) {
if (m["language.valhalla"]({ language }, { locale }) === language) {
return locale;
}
}
@ -33,7 +33,12 @@ export default async function say(text: string, language?: Locale) {
duck();
if (tts !== "web") {
try {
await invoke("plugin:tts|speak", { text, language: language ? m["language.tts"]({}, { locale: language }) : m["language.tts"]() });
await invoke("plugin:tts|speak", {
text,
language: language
? m["language.tts"]({}, { locale: language })
: m["language.tts"](),
});
} catch (e) {
console.error("Error speaking text", e);
alert(e);

View File

@ -348,7 +348,11 @@ function isOnPoint(location: WorldLocation, point: WorldLocation) {
return distance <= tolerance;
}
function isOnShape(location: WorldLocation, shape: WorldLocation[], toleranceMeters = 12) {
function isOnShape(
location: WorldLocation,
shape: WorldLocation[],
toleranceMeters = 12,
) {
for (let i = 0; i < shape.length - 1; i++) {
if (isOnLine(location, shape[i], shape[i + 1], toleranceMeters)) {
return true;

View File

@ -79,12 +79,10 @@ interface StateValue<T> {
}
export const vehicles: WrappedValue<StoreValue<Vehicle>[]> = stores("vehicle");
export const selectedVehicleId: StateValue<string | null> = $state({
v: localStorage.getItem("selectedVehicle") ?? null
v: localStorage.getItem("selectedVehicle") ?? null,
});
export const selectedVehicle: () => StoreValue<Vehicle> | null = () => {
return (
vehicles.current.find((v) => v.id === selectedVehicleId.v) ?? null
);
return vehicles.current.find((v) => v.id === selectedVehicleId.v) ?? null;
};
// export function setVehicles(_vehicles: Vehicle[]) {
@ -103,9 +101,8 @@ export function selectVehicle(vehicle: Vehicle | null) {
if (vehicle == null) {
selectedVehicleId.v = null;
} else {
selectedVehicleId.v = vehicles.current.find(
(v) => v.name === vehicle.name,
)?.id ?? null;
selectedVehicleId.v =
vehicles.current.find((v) => v.name === vehicle.name)?.id ?? null;
}
localStorage.setItem(
"selectedVehicle",