introduced the notification-store, which allows to notify the user about new messages
This commit is contained in:
19
src/stores/notification-store.ts
Normal file
19
src/stores/notification-store.ts
Normal file
@@ -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 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user