koel/resources/assets/js/composables/useSongMenuMethods.ts

41 lines
935 B
TypeScript
Raw Normal View History

2022-07-04 10:39:02 +00:00
import { Ref } from 'vue'
import { favoriteStore, queueStore } from '@/stores'
import { usePlaylistManagement } from '@/composables'
2022-04-15 14:24:30 +00:00
export const useSongMenuMethods = (songs: Ref<Song[]>, close: Closure) => {
const { addSongsToPlaylist } = usePlaylistManagement()
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()
await addSongsToPlaylist(playlist, songs.value)
2022-04-15 14:24:30 +00:00
}
return {
queueSongsAfterCurrent,
queueSongsToBottom,
queueSongsToTop,
addSongsToFavorite,
addSongsToExistingPlaylist
}
}