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(); let marker: HTMLImageElement | undefined = $state();
</script> </script>
<img <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" alt="Work Marker"
bind:this={marker} bind:this={marker}
style="width: 32px;" style="width: 32px;"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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