From 5f51ed4bd7838a778d5f2279e42c12d2671f0cb2 Mon Sep 17 00:00:00 2001 From: space-nuko <24979496+space-nuko@users.noreply.github.com> Date: Thu, 1 Jun 2023 08:51:32 -0500 Subject: [PATCH] Check for existence of Notification safely --- src/lib/components/ComfyApp.ts | 8 +++++--- src/lib/notify.ts | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lib/components/ComfyApp.ts b/src/lib/components/ComfyApp.ts index 2c77775..e4c7625 100644 --- a/src/lib/components/ComfyApp.ts +++ b/src/lib/components/ComfyApp.ts @@ -728,9 +728,11 @@ export default class ComfyApp { } private requestPermissions() { - if (Notification.permission === "default") { - Notification.requestPermission() - .then((result) => console.log("Notification status:", result)); + if (window.Notification != null) { + if (window.Notification.permission === "default") { + window.Notification.requestPermission() + .then((result) => console.log("Notification status:", result)); + } } } diff --git a/src/lib/notify.ts b/src/lib/notify.ts index 80a0f2c..90caee9 100644 --- a/src/lib/notify.ts +++ b/src/lib/notify.ts @@ -92,6 +92,11 @@ function notifyToast(text: string, options: NotifyOptions) { } function notifyNative(text: string, options: NotifyOptions) { + if (window.Notification == null) { + console.warn("[notify] No Notification available on window") + return + } + if (document.hasFocus()) return;