mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 16:54:33 +02:00
avoid live-preview during vae-decode
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
+27
-23
@@ -4,28 +4,32 @@ let lastHeadImg = null;
|
||||
let notificationButton = null;
|
||||
|
||||
async function sendNotification() {
|
||||
if (!notificationButton) {
|
||||
notificationButton = gradioApp().getElementById('request_notifications');
|
||||
if (notificationButton) notificationButton.addEventListener('click', (evt) => Notification.requestPermission(), true);
|
||||
try {
|
||||
if (!notificationButton) {
|
||||
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
|
||||
let galleryPreviews = gradioApp().querySelectorAll('div[id^="tab_"][style*="display: block"] div[id$="_results"] .thumbnail-item > img');
|
||||
if (!galleryPreviews || galleryPreviews.length === 0) galleryPreviews = gradioApp().querySelectorAll('.thumbnail-item > img');
|
||||
if (!galleryPreviews || galleryPreviews.length === 0) return;
|
||||
const headImg = galleryPreviews[0]?.src;
|
||||
if (!headImg || headImg === lastHeadImg || headImg.includes('logo-bg-')) return;
|
||||
const audioNotification = gradioApp().querySelector('#audio_notification audio');
|
||||
if (audioNotification) audioNotification.play();
|
||||
lastHeadImg = 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', {
|
||||
body: `Generated ${imgs.size > 1 ? imgs.size - opts.return_grid : 1} image${imgs.size > 1 ? 's' : ''}`,
|
||||
icon: headImg,
|
||||
image: headImg,
|
||||
});
|
||||
notification.onclick = () => {
|
||||
parent.focus();
|
||||
this.close();
|
||||
};
|
||||
log('sendNotifications');
|
||||
} catch (e) {
|
||||
error(`sendNotification: ${e}`);
|
||||
}
|
||||
if (document.hasFocus()) return; // window is in focus so don't send notifications
|
||||
let galleryPreviews = gradioApp().querySelectorAll('div[id^="tab_"][style*="display: block"] div[id$="_results"] .thumbnail-item > img');
|
||||
if (!galleryPreviews || galleryPreviews.length === 0) galleryPreviews = gradioApp().querySelectorAll('.thumbnail-item > img');
|
||||
if (!galleryPreviews || galleryPreviews.length === 0) return;
|
||||
const headImg = galleryPreviews[0]?.src;
|
||||
if (!headImg || headImg === lastHeadImg || headImg.includes('logo-bg-')) return;
|
||||
const audioNotification = gradioApp().querySelector('#audio_notification audio');
|
||||
if (audioNotification) audioNotification.play();
|
||||
lastHeadImg = 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', {
|
||||
body: `Generated ${imgs.size > 1 ? imgs.size - opts.return_grid : 1} image${imgs.size > 1 ? 's' : ''}`,
|
||||
icon: headImg,
|
||||
image: headImg,
|
||||
});
|
||||
notification.onclick = () => {
|
||||
parent.focus();
|
||||
this.close();
|
||||
};
|
||||
log('sendNotifications');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user