aboutsummaryrefslogtreecommitdiff
path: root/src-vue/src/utils/ui.ts
diff options
context:
space:
mode:
authorRémy Raes <contact@remyraes.com>2023-10-16 16:17:37 +0200
committerGitHub <noreply@github.com>2023-10-16 16:17:37 +0200
commit07ca1acee9a5f4227d18766b49b3fe6c8690e9a1 (patch)
tree824f2e659536dc9a5eb10f6e99bfb16da3d65647 /src-vue/src/utils/ui.ts
parent4ddf57e0024dcd70a39473b15bbe1a0e1f69db88 (diff)
downloadFlightCore-07ca1acee9a5f4227d18766b49b3fe6c8690e9a1.tar.gz
FlightCore-07ca1acee9a5f4227d18766b49b3fe6c8690e9a1.zip
feat: Notification menu (#615)
Introduces a notification menu, which hosts notifications fired while the app was not focused. Notifications can be closed by the user.
Diffstat (limited to 'src-vue/src/utils/ui.ts')
-rw-r--r--src-vue/src/utils/ui.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/src-vue/src/utils/ui.ts b/src-vue/src/utils/ui.ts
index b84d7666..4c735a9c 100644
--- a/src-vue/src/utils/ui.ts
+++ b/src-vue/src/utils/ui.ts
@@ -1,8 +1,10 @@
import { ElNotification, NotificationHandle } from "element-plus";
import { i18n } from "../main";
+import { store } from "../plugins/store";
/**
* Displays content to the user in the form of a notification appearing on screen bottom right.
+ * If the app is not focused when this is invoked, a notification is added to the notifications menu.
**/
function showNotification(
title: string,
@@ -10,6 +12,10 @@ function showNotification(
type: 'success' | 'warning' | 'error' | 'info' = 'success',
duration: number = 4500
): NotificationHandle {
+ if (!document.hasFocus()) {
+ store.commit('addNotification', {title, text: message, type});
+ }
+
return ElNotification({
title, message, type, duration,
position: 'bottom-right',