diff --git a/src/lib/components/layout/Toasts.svelte b/src/lib/components/layout/Toasts.svelte new file mode 100644 index 0000000..ddf9d57 --- /dev/null +++ b/src/lib/components/layout/Toasts.svelte @@ -0,0 +1,15 @@ + + +
+ {#each toastList as { id, type, message, durations }} + + {/each} +
diff --git a/src/lib/components/layout/index.ts b/src/lib/components/layout/index.ts index e3c43d5..b13e481 100644 --- a/src/lib/components/layout/index.ts +++ b/src/lib/components/layout/index.ts @@ -1,5 +1,6 @@ export { default as UploadRegion } from './UploadRegion.svelte'; export { default as Gradients } from './Gradients.svelte'; +export { default as Toasts } from './Toasts.svelte'; export { default as Dialogs } from './Dialogs.svelte'; export { default as PageContent } from './PageContent.svelte'; export { default as MobileLogo } from './MobileLogo.svelte'; diff --git a/src/lib/components/visual/Toast.svelte b/src/lib/components/visual/Toast.svelte index 5fa413f..351df0d 100644 --- a/src/lib/components/visual/Toast.svelte +++ b/src/lib/components/visual/Toast.svelte @@ -1,78 +1,78 @@
-
- -

{message}

-
- -
\ No newline at end of file +
+ +

{message}

+
+ + diff --git a/src/lib/store/ToastProvider.ts b/src/lib/store/ToastProvider.ts index f696266..9e28267 100644 --- a/src/lib/store/ToastProvider.ts +++ b/src/lib/store/ToastProvider.ts @@ -47,6 +47,8 @@ function addToast( }, durations.enter + durations.stay + durations.exit, ); + + return id; } function removeToast(id: number) { diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index adcb611..91ca891 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -4,11 +4,9 @@ import { PUB_HOSTNAME, PUB_PLAUSIBLE_URL } from "$env/static/public"; import { VERT_NAME } from "$lib/consts"; - import Toast from "$lib/components/visual/Toast.svelte"; import * as Layout from "$lib/components/layout"; import * as Navbar from "$lib/components/layout/Navbar"; import featuredImage from "$lib/assets/VERT_Feature.webp"; - import { type Toast as ToastType, toasts } from "$lib/store/ToastProvider"; import { Settings } from "$lib/sections/settings/index.svelte"; import { files, @@ -21,12 +19,6 @@ let { children } = $props(); - let toastList = $state([]); - - toasts.subscribe((value) => { - toastList = value as ToastType[]; - }); - const dropFiles = (e: DragEvent) => { e.preventDefault(); dropping.set(false); @@ -116,12 +108,7 @@ --> -
- {#each toastList as { id, type, message, durations }} - - {/each} -
- +
diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte index 6419056..c8ab691 100644 --- a/src/routes/settings/+page.svelte +++ b/src/routes/settings/+page.svelte @@ -16,17 +16,18 @@ isInitial = false; return; } - settings; + const savedSettings = localStorage.getItem("settings"); if (savedSettings) { const parsedSettings = JSON.parse(savedSettings); - if (parsedSettings === settings) return; + if (JSON.stringify(parsedSettings) === JSON.stringify(settings)) + return; } - log(["settings"], "saving settings"); try { Settings.Settings.instance.settings = settings; Settings.Settings.instance.save(); + log(["settings"], "saving settings"); } catch (error) { log(["settings", "error"], `failed to save settings: ${error}`); addToast("error", "Failed to save settings!");