2022-04-15 14:24:30 +00:00
|
|
|
import { favoriteStore, playlistStore, queueStore } from '@/stores'
|
2022-04-20 10:20:09 +00:00
|
|
|
import { Ref } from 'vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Includes the methods trigger-able on a song (context) menu.
|
|
|
|
* Each component including this mixin must have a `songs` array as either data, prop, or computed.
|
|
|
|
*/
|
2022-04-20 10:20:09 +00:00
|
|
|
export const useSongMenuMethods = (songs: Ref<Song[]>, close: TAnyFunction) => {
|
2022-04-15 14:24:30 +00:00
|
|
|
const queueSongsAfterCurrent = () => {
|
2022-04-20 10:20:09 +00:00
|
|
|
queueStore.queueAfterCurrent(songs.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
close()
|
|
|
|
}
|
|
|
|
|
|
|
|
const queueSongsToBottom = () => {
|
2022-04-20 10:20:09 +00:00
|
|
|
queueStore.queue(songs.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
close()
|
|
|
|
}
|
|
|
|
|
|
|
|
const queueSongsToTop = () => {
|
2022-04-20 10:20:09 +00:00
|
|
|
queueStore.queueToTop(songs.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
close()
|
|
|
|
}
|
|
|
|
|
|
|
|
const addSongsToFavorite = async () => {
|
2022-04-20 10:20:09 +00:00
|
|
|
await favoriteStore.like(songs.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
close()
|
|
|
|
}
|
|
|
|
|
|
|
|
const addSongsToExistingPlaylist = async (playlist: Playlist) => {
|
2022-04-20 10:20:09 +00:00
|
|
|
await playlistStore.addSongs(playlist, songs.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
close()
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
queueSongsAfterCurrent,
|
|
|
|
queueSongsToBottom,
|
|
|
|
queueSongsToTop,
|
|
|
|
addSongsToFavorite,
|
|
|
|
addSongsToExistingPlaylist
|
|
|
|
}
|
|
|
|
}
|