mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-26 09:50:33 +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)
|
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 {
|
return {
|
||||||
add,
|
add,
|
||||||
remove
|
remove,
|
||||||
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user