mirror of
https://github.com/vladmandic/automatic
synced 2026-08-29 16:41:01 +02:00
fix notifications
This commit is contained in:
@@ -41,7 +41,7 @@ async function logMonitor() {
|
||||
document.getElementById('logWarnings').innerText = logWarnings;
|
||||
document.getElementById('logErrors').innerText = logErrors;
|
||||
const modenUIBtn = document.getElementById('btn_console');
|
||||
if (modenUIBtn) modenUIBtn.setAttribute('error-count', logErrors);
|
||||
if (modenUIBtn) modenUIBtn.setAttribute('error-count', logErrors > 0 ? logErrors : '');
|
||||
};
|
||||
|
||||
if (logMonitorStatus) setTimeout(logMonitor, opts.logmonitor_refresh_period);
|
||||
|
||||
@@ -3,14 +3,15 @@
|
||||
let lastHeadImg = null;
|
||||
let notificationButton = null;
|
||||
|
||||
async function initNotifications() {
|
||||
async function sendNotification() {
|
||||
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
|
||||
const galleryPreviews = gradioApp().querySelectorAll('div[id^="tab_"][style*="display: block"] div[id$="_results"] .thumbnail-item > img');
|
||||
if (!galleryPreviews) return;
|
||||
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');
|
||||
@@ -26,5 +27,5 @@ async function initNotifications() {
|
||||
parent.focus();
|
||||
this.close();
|
||||
};
|
||||
log('sendNotification');
|
||||
log('sendNotifications');
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ function requestProgress(id_task, progressEl, galleryEl, atEnd = null, onProgres
|
||||
setProgress();
|
||||
if (parentGallery && livePreview) parentGallery.removeChild(livePreview);
|
||||
checkPaused(true);
|
||||
sendNotification();
|
||||
if (atEnd) atEnd();
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ async function initStartup() {
|
||||
initModels();
|
||||
getUIDefaults();
|
||||
initiGenerationParams();
|
||||
initNotifications();
|
||||
initPromptChecker();
|
||||
initLogMonitor();
|
||||
initContextMenu();
|
||||
|
||||
Reference in New Issue
Block a user