remove relatime notification subscription
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import {
|
||||||
beforeNavigate,
|
beforeNavigate,
|
||||||
goto,
|
goto,
|
||||||
invalidate,
|
invalidate,
|
||||||
invalidateAll
|
invalidateAll,
|
||||||
} from "$app/navigation";
|
} from "$app/navigation";
|
||||||
|
|
||||||
import { page } from "$app/state";
|
import { page } from "$app/state";
|
||||||
import { env } from "$env/dynamic/public";
|
import { env } from "$env/dynamic/public";
|
||||||
import Toast from "$lib/components/base/toast.svelte";
|
import Toast from "$lib/components/base/toast.svelte";
|
||||||
@@ -23,36 +23,27 @@
|
|||||||
import type { LayoutData } from "./$types";
|
import type { LayoutData } from "./$types";
|
||||||
import PocketBase from "pocketbase";
|
import PocketBase from "pocketbase";
|
||||||
import { browser } from "$app/environment";
|
import { browser } from "$app/environment";
|
||||||
|
|
||||||
interface Props { data: LayoutData; children?: Snippet }
|
interface Props {
|
||||||
|
data: LayoutData;
|
||||||
|
children?: Snippet;
|
||||||
|
}
|
||||||
|
|
||||||
let { data, children }: Props = $props();
|
let { data, children }: Props = $props();
|
||||||
|
|
||||||
beforeNavigate((n) => {
|
beforeNavigate((n) => {
|
||||||
if (!$currentUser && isRouteProtected(n.to?.url)) {
|
if (!$currentUser && isRouteProtected(n.to?.url)) {
|
||||||
n.cancel();
|
n.cancel();
|
||||||
goto("/login?r=" + n.to?.url?.pathname);
|
goto("/login?r=" + n.to?.url?.pathname);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (page.data.origin != location.origin) {
|
if (page.data.origin != location.origin) {
|
||||||
showWarning = true;
|
showWarning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pb = new PocketBase(env.PUBLIC_POCKETBASE_URL);
|
|
||||||
|
|
||||||
if (browser) {
|
|
||||||
pb.authStore.loadFromCookie(document.cookie);
|
|
||||||
}
|
|
||||||
|
|
||||||
pb.collection("notifications").subscribe("*", async (e) => {
|
|
||||||
if (e.action === "create") {
|
|
||||||
await invalidateAll();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let hideDemoHint = $state(false);
|
let hideDemoHint = $state(false);
|
||||||
let showWarning = $state(false);
|
let showWarning = $state(false);
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user