2022-07-04 10:39:02 +00:00
|
|
|
import { Ref } from 'vue'
|
2022-10-24 15:27:17 +00:00
|
|
|
import { favoriteStore, queueStore } from '@/stores'
|
|
|
|
import { usePlaylistManagement } from '@/composables'
|
2022-12-06 10:28:48 +00:00
|
|
|
import { eventBus } from '@/utils'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-05-05 15:30:10 +00:00
|
|
|
export const useSongMenuMethods = (songs: Ref<Song[]>, close: Closure) => {
|
2022-10-24 15:27:17 +00:00
|
|
|
const { addSongsToPlaylist } = usePlaylistManagement()
|
2022-07-26 09:51:19 +00:00
|
|
|
|
2022-04-15 14:24:30 +00:00
|
|
|
const queueSongsAfterCurrent = () => {
|
|
|
|
close()
|
2022-06-10 10:47:46 +00:00
|
|
|
queueStore.queueAfterCurrent(songs.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const queueSongsToBottom = () => {
|
|
|
|
close()
|
2022-06-10 10:47:46 +00:00
|
|
|
queueStore.queue(songs.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const queueSongsToTop = () => {
|
|
|
|
close()
|
2022-06-10 10:47:46 +00:00
|
|
|
queueStore.queueToTop(songs.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const addSongsToFavorite = async () => {
|
|
|
|
close()
|
2022-06-10 10:47:46 +00:00
|
|
|
await favoriteStore.like(songs.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const addSongsToExistingPlaylist = async (playlist: Playlist) => {
|
|
|
|
close()
|
2022-10-24 15:27:17 +00:00
|
|
|
await addSongsToPlaylist(playlist, songs.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
2022-12-06 10:28:48 +00:00
|
|
|
const addSongsToNewPlaylist = () => {
|
|
|
|
close()
|
|
|
|
eventBus.emit('MODAL_SHOW_CREATE_PLAYLIST_FORM', null, songs.value)
|
|
|
|
}
|
|
|
|
|
2022-04-15 14:24:30 +00:00
|
|
|
return {
|
|
|
|
queueSongsAfterCurrent,
|
|
|
|
queueSongsToBottom,
|
|
|
|
queueSongsToTop,
|
|
|
|
addSongsToFavorite,
|
2022-12-06 10:28:48 +00:00
|
|
|
addSongsToExistingPlaylist,
|
|
|
|
addSongsToNewPlaylist
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
}
|