2024-10-13 17:37:01 +00:00
|
|
|
import type { Ref } from 'vue'
|
2024-05-19 05:49:42 +00:00
|
|
|
import { favoriteStore, queueStore } from '@/stores'
|
|
|
|
import { usePlaylistManagement } from '@/composables'
|
|
|
|
import { eventBus } from '@/utils'
|
|
|
|
|
|
|
|
export const usePlayableMenuMethods = (playables: Ref<Playable[]>, close: Closure) => {
|
|
|
|
const { addToPlaylist } = usePlaylistManagement()
|
|
|
|
|
|
|
|
const trigger = async (cb: Closure) => {
|
|
|
|
close()
|
|
|
|
await cb()
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
queueAfterCurrent: () => trigger(() => queueStore.queueAfterCurrent(playables.value)),
|
|
|
|
queueToBottom: () => trigger(() => queueStore.queue(playables.value)),
|
|
|
|
queueToTop: () => trigger(() => queueStore.queueToTop(playables.value)),
|
|
|
|
addToFavorites: () => trigger(() => favoriteStore.like(playables.value)),
|
|
|
|
addToExistingPlaylist: (playlist: Playlist) => trigger(() => addToPlaylist(playlist, playables.value)),
|
2024-10-13 17:37:01 +00:00
|
|
|
addToNewPlaylist: () => trigger(() => eventBus.emit('MODAL_SHOW_CREATE_PLAYLIST_FORM', null, playables.value)),
|
2024-05-19 05:49:42 +00:00
|
|
|
}
|
|
|
|
}
|