solve issue #19

This commit is contained in:
Sockenklaus
2021-10-23 08:11:00 +02:00
parent a323cf862a
commit 2851a762a6
5 changed files with 60 additions and 36 deletions

View File

@@ -1,16 +1,27 @@
import { defineStore, acceptHMRUpdate } from 'pinia'
import { v4 as uuidv4 } from 'uuid'
export const useNotifications = defineStore('notifications', {
state: () => {
return {
/**@type {{type: string, text: string, randomKey: string}[]} */
notifications: new Array<{type: string, text: string, randomKey: string}>()
/**@type {Map<string, {type: string, text: string}>} */
notifications: new Map<string, {type: string, text: string}>()
}
},
actions: {
removeAlert(index : number) : void {
this.notifications.splice(index, 1)
remove(id : string) : void {
this.notifications.delete(id)
},
add(type : string, text: string) : void {
this.notifications.set(
uuidv4(),
{
type:type,
text:text,
}
)
}
}
})