fix: restore message toast after playlist deletion

This commit is contained in:
Phan An 2022-07-26 16:59:19 +02:00
parent 6f6f9a0839
commit f0f953568c
No known key found for this signature in database
GPG key ID: A81E4477F0BB6FDC
2 changed files with 5 additions and 3 deletions

View file

@ -1,14 +1,14 @@
<template>
<TransitionGroup name="toast" tag="ul">
<li v-for="message in messages" :key="message.id">
<MessageToastItem :message="message" @dismiss="removeMessage(message)"/>
<MessageToast :message="message" @dismiss="removeMessage(message)"/>
</li>
</TransitionGroup>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import MessageToastItem from '@/components/ui/MessageToastItem.vue'
import MessageToast from '@/components/ui/MessageToast.vue'
const messages = ref<ToastMessage[]>([])

View file

@ -11,14 +11,16 @@ import router from '@/router'
import { authService } from '@/services'
import { playlistStore, preferenceStore, userStore } from '@/stores'
import { eventBus, forceReloadWindow, requireInjection } from '@/utils'
import { DialogBoxKey } from '@/symbols'
import { DialogBoxKey, MessageToasterKey } from '@/symbols'
const toaster = requireInjection(MessageToasterKey)
const dialog = requireInjection(DialogBoxKey)
eventBus.on({
'PLAYLIST_DELETE': async (playlist: Playlist) => {
if (await dialog.value.confirm(`Are you sure you want to delete "${playlist.name}"?`, 'Delete Playlist')) {
await playlistStore.delete(playlist)
toaster.value.success(`Playlist "${playlist.name}" deleted.`)
router.go('home')
}
},