Check for existence of Notification safely

This commit is contained in:
space-nuko
2023-06-01 08:51:32 -05:00
parent 173e9aa61a
commit 5f51ed4bd7
2 changed files with 10 additions and 3 deletions

View File

@@ -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));
}
}
}

View File

@@ -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;