Add toast message on refresh button click (#492)

This commit is contained in:
Chenlei Hu
2024-08-17 13:11:47 -04:00
committed by GitHub
parent 966b1dd057
commit 5ba524fd94
3 changed files with 52 additions and 6 deletions

View File

@@ -12,7 +12,7 @@ const toast = useToast()
const toastStore = useToastStore()
watch(
() => toastStore.messages,
() => toastStore.messagesToAdd,
(newMessages) => {
if (newMessages.length === 0) {
return
@@ -21,8 +21,33 @@ watch(
newMessages.forEach((message) => {
toast.add(message)
})
toastStore.removeAll()
toastStore.messagesToAdd = []
},
{ deep: true }
)
watch(
() => toastStore.messagesToRemove,
(messagesToRemove) => {
if (messagesToRemove.length === 0) {
return
}
messagesToRemove.forEach((message) => {
toast.remove(message)
})
toastStore.messagesToRemove = []
},
{ deep: true }
)
watch(
() => toastStore.removeAllRequested,
(requested) => {
if (requested) {
toast.removeAllGroups()
toastStore.removeAllRequested = false
}
}
)
</script>