diff --git a/src/runtime/composables/useToast.ts b/src/runtime/composables/useToast.ts index b3a23259..1e7143da 100644 --- a/src/runtime/composables/useToast.ts +++ b/src/runtime/composables/useToast.ts @@ -22,8 +22,17 @@ export function useToast () { notifications.value = notifications.value.filter((n: Notification) => n.id !== id) } + function update (id: string, notification: Partial) { + 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 } }