From e7b88e6a50c06b7c9bdbc2b2d1b1724325b34745 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Wed, 3 May 2023 18:40:34 -0400 Subject: [PATCH] fix notifications --- javascript/notification.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/javascript/notification.js b/javascript/notification.js index d443d5474..517cb42c1 100644 --- a/javascript/notification.js +++ b/javascript/notification.js @@ -8,18 +8,14 @@ onUiUpdate(function(){ notificationButton = gradioApp().getElementById('request_notifications') if (notificationButton) notificationButton.addEventListener('click', (evt) => Notification.requestPermission(), true); } + if (document.hasFocus()) return; // window is in focus so don't send notifications const galleryPreviews = gradioApp().querySelectorAll('div[id^="tab_"][style*="display: block"] div[id$="_results"] .thumbnail-item > img'); if (!galleryPreviews) return; - - if (document.hasFocus()) return; // window is in focus so don't send notifications - - const audioNotification = gradioApp().querySelector('#audio_notification audio'); - if (audioNotification) audioNotification.play(); - const headImg = galleryPreviews[0]?.src; if (!headImg || headImg == lastHeadImg || headImg.endsWith('automatic.png')) return; + const audioNotification = gradioApp().querySelector('#audio_notification audio'); + if (audioNotification) audioNotification.play(); lastHeadImg = headImg; - console.log(headImg) const imgs = new Set(Array.from(galleryPreviews).map(img => img.src)); // Multiple copies of the images are in the DOM when one is selected const notification = new Notification( 'SD.Next', {