diff --git a/src/lib/components/lnv/FullscreenMap.svelte b/src/lib/components/lnv/FullscreenMap.svelte
index 6c3e094..04424de 100644
--- a/src/lib/components/lnv/FullscreenMap.svelte
+++ b/src/lib/components/lnv/FullscreenMap.svelte
@@ -19,6 +19,7 @@
import { PMTilesProtocol } from "svelte-maplibre-gl/pmtiles";
import HazardMarker from "./HazardMarker.svelte";
import { hazards } from "./hazards.svelte";
+ import RequiresCapability from "./RequiresCapability.svelte";
onMount(() => {
window.addEventListener("resize", map.updateMapPadding);
@@ -181,12 +182,13 @@
/>
{/if}
-
- {#each hazards as hazard (hazard.latitude + "-" + hazard.longitude)}
-
- {/each}
+
+ {#each hazards as hazard (hazard.latitude + "-" + hazard.longitude)}
+
+ {/each}
+
diff --git a/src/lib/components/lnv/hazards.svelte.ts b/src/lib/components/lnv/hazards.svelte.ts
index ecacec5..cb29399 100644
--- a/src/lib/components/lnv/hazards.svelte.ts
+++ b/src/lib/components/lnv/hazards.svelte.ts
@@ -1,10 +1,11 @@
-import { getHazards, type Hazard } from "$lib/services/lnv";
+import { getHazards, hasCapability, type Hazard } from "$lib/services/lnv";
import { location } from "./location.svelte";
export const hazards: Hazard[] = $state([]);
export async function fetchHazards() {
if (!location.available) return;
+ if (!await hasCapability("hazards")) return;
const newHazards = await getHazards(
{ lat: location.lat, lon: location.lng },
100,
diff --git a/src/lib/services/lnv.ts b/src/lib/services/lnv.ts
index e9439f6..6cdd1bd 100644
--- a/src/lib/services/lnv.ts
+++ b/src/lib/services/lnv.ts
@@ -1,6 +1,5 @@
import { LNV_SERVER } from "./hosts";
import type { OIDCUser } from "./oidc";
-import type { Store } from "./stores";
export type Capabilities = (
| "auth"
@@ -9,6 +8,8 @@ export type Capabilities = (
| "fuel"
| "post"
| "saved-routes"
+ | "hazards"
+ | "stores"
)[];
export let capabilities: Capabilities = [];
export let oidcConfig: {
@@ -240,9 +241,9 @@ export interface Hazard {
}
export async function getHazards(location: WorldLocation, radius = 50) {
- // if (!(await hasCapability("hazards"))) {
- // throw new Error("Hazards capability is not available");
- // }
+ if (!(await hasCapability("hazards"))) {
+ throw new Error("Hazards capability is not available");
+ }
const res = await fetch(
LNV_SERVER +
`/hazards?lat=${location.lat}&lon=${location.lon}&radius=${radius}`,
@@ -255,9 +256,9 @@ export async function getHazards(location: WorldLocation, radius = 50) {
}
export async function postHazard(location: WorldLocation, type: string) {
- // if (!(await hasCapability("hazards"))) {
- // throw new Error("Hazards capability is not available");
- // }
+ if (!(await hasCapability("hazards"))) {
+ throw new Error("Hazards capability is not available");
+ }
const res = await authFetch(LNV_SERVER + `/hazards`, {
method: "POST",
headers: {
@@ -274,32 +275,3 @@ export async function postHazard(location: WorldLocation, type: string) {
}
return await res.json();
}
-
-export function getStores(): Promise {
- return authFetch(LNV_SERVER + "/stores").then((res) => res.json());
-}
-
-export function getStore(name: string): Promise {
- return authFetch(LNV_SERVER + "/store/" + name).then((res) => res.json());
-}
-
-export function putStore(name: string, data: object, type: string, privacy: string) {
- return authFetch(LNV_SERVER + "/store", {
- method: "PUT",
- body: JSON.stringify({
- name,
- data: JSON.stringify(data),
- type,
- privacy,
- }),
- });
-}
-
-export function deleteStore(name: string) {
- return authFetch(LNV_SERVER + "/store", {
- method: "DELETE",
- body: JSON.stringify({
- name,
- }),
- }).then((res) => res.text());
-}