From a57f0c11e8a58128bc0eb5822a169dae489d8e97 Mon Sep 17 00:00:00 2001 From: joschuatonn Date: Sun, 16 Jun 2024 18:04:52 +0200 Subject: [PATCH] introduced the notification-store, which allows to notify the user about new messages --- src/stores/notification-store.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/stores/notification-store.ts diff --git a/src/stores/notification-store.ts b/src/stores/notification-store.ts new file mode 100644 index 0000000..22427a6 --- /dev/null +++ b/src/stores/notification-store.ts @@ -0,0 +1,19 @@ +import { defineStore } from 'pinia'; + +export const useNotificationStore = defineStore('notificationStore',{ + state:() => ({ + decision: false, + isTabActive: true, + }), + actions: { + saveDecision(decision : boolean) { + this.decision = decision; + }, + + sendNotificationIfAllowed(image : string, headline : string, message : string) { + if(this.decision && !this.isTabActive){ + new Notification(headline, { body: message, icon: image }); + } + } + } +});