mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
feat(useToast): allow updating an existing notification (#1668)
This commit is contained in:
@@ -22,8 +22,17 @@ export function useToast () {
|
||||
notifications.value = notifications.value.filter((n: Notification) => n.id !== id)
|
||||
}
|
||||
|
||||
function update (id: string, notification: Partial<Notification>) {
|
||||
const index = notifications.value.findIndex((n: Notification) => n.id === id)
|
||||
if (index !== -1) {
|
||||
const previous = notifications.value[index]
|
||||
notifications.value.splice(index, 1, { ...previous, ...notification })
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
add,
|
||||
remove
|
||||
remove,
|
||||
update
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user