diff --git a/app/library/DownloadQueue.py b/app/library/DownloadQueue.py index 89baefea..ff5cb171 100644 --- a/app/library/DownloadQueue.py +++ b/app/library/DownloadQueue.py @@ -335,9 +335,8 @@ class DownloadQueue(metaclass=Singleton): if "is_upcoming" == entry.get("live_status"): NotifyEvent = Events.COMPLETED dlInfo.info.status = "not_live" - dlInfo.info.msg = ( - f"{'Premiere video' if is_premiere else 'Stream' } is not available yet." + text_logs - ) + dlInfo.info.msg = f"{'Premiere video' if is_premiere else 'Stream' } is not available yet." + text_logs + await self._notify.emit(Events.LOG_INFO, data=event_info(dlInfo.info.msg, {"lowPriority": True})) itemDownload: Download = self.done.put(dlInfo) elif len(entry.get("formats", [])) < 1: availability: str = entry.get("availability", "public") @@ -379,9 +378,7 @@ class DownloadQueue(metaclass=Singleton): NotifyEvent = Events.COMPLETED await self._notify.emit( Events.LOG_INFO, - data=event_info( - f"'{dl.title}' is premiering. Download delayed by '{300+dl.extras.get('duration')}'s." - ), + data=event_info(f"'{dl.title}' is {dlInfo.info.error}.", {"lowPriority": True}), ) else: NotifyEvent = Events.ADDED diff --git a/ui/composables/useNotification.ts b/ui/composables/useNotification.ts index 62d2a79b..eb252a74 100644 --- a/ui/composables/useNotification.ts +++ b/ui/composables/useNotification.ts @@ -14,10 +14,11 @@ export interface Notification { export interface notificationOptions { timeout?: number, force?: boolean, - store?: boolean, closeOnClick?: boolean, position?: POSITION onClick?: (closeToast: Function) => void + store?: boolean, + lowPriority?: boolean } const allowToast = useStorage('allow_toasts', true) @@ -28,15 +29,20 @@ const toast = useToast() function notify(type: notificationType, message: string, opts?: notificationOptions): void { const notificationStore = useNotificationStore() + if (!opts) { + opts = {} + } + let id: string = '' const force = opts?.force || false; const store = opts?.store || true; + const lowPriority = opts?.lowPriority || false; - if (store && notificationStore) { + if (notificationStore && (store || true === lowPriority)) { id = notificationStore.add(type, message, false) } - if (false === allowToast.value && false === force) { + if (true === lowPriority || (false === allowToast.value && false === force)) { return; } @@ -44,14 +50,6 @@ function notify(type: notificationType, message: string, opts?: notificationOpti return; } - if (!opts) { - opts = {} - } - - if (opts?.force) { - delete opts.force - } - opts.closeOnClick = toastDismissOnClick.value opts.position = toastPosition.value ?? POSITION.TOP_RIGHT opts.onClick = (closeToast: Function) => { @@ -88,5 +86,6 @@ export default function useNotification() { success: (message: string, opts?: notificationOptions) => notify('success', message, opts), warning: (message: string, opts?: notificationOptions) => notify('warning', message, opts), error: (message: string, opts?: notificationOptions) => notify('error', message, opts), + notify } } diff --git a/ui/stores/SocketStore.js b/ui/stores/SocketStore.js index 8aafdd51..3b9b628e 100644 --- a/ui/stores/SocketStore.js +++ b/ui/stores/SocketStore.js @@ -51,27 +51,27 @@ export const useSocketStore = defineStore('socket', () => { socket.value.on('error', stream => { const json = JSON.parse(stream); - toast.error(`${json.data?.id ?? json?.type}: ${json?.message}`); + toast.error(`${json.data?.id ?? json?.type}: ${json?.message}`, json.data || {}); }); socket.value.on('log_info', stream => { const json = JSON.parse(stream); - toast.info(json?.message); + toast.info(json?.message, json.data || {}); }); socket.value.on('log_success', stream => { const json = JSON.parse(stream); - toast.success(json?.message); + toast.success(json?.message, json.data || {}); }); socket.value.on('log_warning', stream => { const json = JSON.parse(stream); - toast.warning(json?.message); + toast.warning(json?.message, json.data || {}); }); socket.value.on('log_error', stream => { const json = JSON.parse(stream); - toast.error(json?.message); + toast.error(json?.message, json.data || {}); }); socket.value.on('completed', stream => {