web: wrap error handler in onMount

This commit is contained in:
dumbmoron 2024-09-03 13:30:32 +00:00
parent 93f8c038d2
commit f009da7de4
No known key found for this signature in database

View file

@ -2,8 +2,9 @@
import { goto } from "$app/navigation"; import { goto } from "$app/navigation";
import { page } from "$app/stores"; import { page } from "$app/stores";
import { defaultSettingsPage } from "$lib/settings/defaults"; import { defaultSettingsPage } from "$lib/settings/defaults";
import { onMount } from "svelte";
$: { onMount(() => {
if ($page.error?.message === "Not Found") { if ($page.error?.message === "Not Found") {
if ($page.url.pathname.startsWith("/settings")) { if ($page.url.pathname.startsWith("/settings")) {
goto(defaultSettingsPage(), { replaceState: true }); goto(defaultSettingsPage(), { replaceState: true });
@ -11,5 +12,5 @@
goto("/", { replaceState: true }); goto("/", { replaceState: true });
} }
} }
} });
</script> </script>