From 16c76e7e9216465011480cbb99c48ba6c6f3740e Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Thu, 4 Jul 2024 22:18:02 +0000 Subject: [PATCH] web/settings: redirect invalid settings paths to default settings page --- web/src/lib/settings/defaults.ts | 12 ++++++++++++ web/src/routes/+error.svelte | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 web/src/routes/+error.svelte diff --git a/web/src/lib/settings/defaults.ts b/web/src/lib/settings/defaults.ts index 362696ff..33d35603 100644 --- a/web/src/lib/settings/defaults.ts +++ b/web/src/lib/settings/defaults.ts @@ -1,3 +1,4 @@ +import { browser } from "$app/environment"; import { defaultLocale } from "$lib/i18n/translations"; import type { CobaltSettings } from "$lib/types/settings"; @@ -35,4 +36,15 @@ const defaultSettings: CobaltSettings = { }, } +const defaultSettingsPage = () => { + if (browser) { + if (window.innerWidth <= 750) { + return "/settings"; + } + } + + return "/settings/general/appearance"; +} + export default defaultSettings; +export { defaultSettingsPage }; \ No newline at end of file diff --git a/web/src/routes/+error.svelte b/web/src/routes/+error.svelte new file mode 100644 index 00000000..ba0b6166 --- /dev/null +++ b/web/src/routes/+error.svelte @@ -0,0 +1,17 @@ + + + +

{$page.status}: {$page.error?.message}

\ No newline at end of file