('toast_dismiss_on_click', true)
const toast = useToast()
function notify(type: notificationType, message: string, opts?: notificationOptions): void {
- let force = opts?.force || false;
+ const notificationStore = useNotificationStore()
+
+ let id: string = ''
+ const force = opts?.force || false;
+ const store = opts?.store || true;
+
+ if (store && notificationStore) {
+ id = notificationStore.add(type, message, false)
+ }
+
if (false === allowToast.value && false === force) {
return;
}
+ if (false === document.hasFocus()) {
+ return;
+ }
+
if (!opts) {
opts = {}
}
@@ -30,6 +54,14 @@ function notify(type: notificationType, message: string, opts?: notificationOpti
opts.closeOnClick = toastDismissOnClick.value
opts.position = toastPosition.value ?? POSITION.TOP_RIGHT
+ opts.onClick = (closeToast: Function) => {
+ if (opts?.closeOnClick !== false) {
+ closeToast()
+ }
+ if (notificationStore) {
+ notificationStore.markRead(id)
+ }
+ }
switch (type) {
case 'info':
diff --git a/ui/layouts/default.vue b/ui/layouts/default.vue
index 9319a463..ad43a523 100644
--- a/ui/layouts/default.vue
+++ b/ui/layouts/default.vue
@@ -86,6 +86,8 @@
+
+