From afcbf2cafbb00e1571675adedb17b07cbdaeebfe Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sat, 4 Jan 2025 02:15:57 -0800 Subject: [PATCH] enh: native notifications --- src/routes/+layout.svelte | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index fc4bd1c8f..8866c050c 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -10,6 +10,7 @@ import { config, user, + settings, theme, WEBUI_NAME, mobile, @@ -107,6 +108,13 @@ const { done, content, title } = data; if (done) { + if ($settings?.notificationEnabled ?? false) { + const notification = new Notification(`${title} | Open WebUI`, { + body: content, + icon: `${WEBUI_BASE_URL}/static/favicon.png` + }); + } + toast.custom(NotificationToast, { componentProps: { onClick: () => { @@ -138,6 +146,13 @@ const data = event?.data?.data ?? null; if (type === 'message') { + if ($settings?.notificationEnabled ?? false) { + new Notification(`#${event?.channel?.name} | Open WebUI`, { + body: data?.content, + icon: `${WEBUI_BASE_URL}/static/favicon.png` + }); + } + toast.custom(NotificationToast, { componentProps: { onClick: () => {