2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<section id="queueWrapper">
|
2022-04-20 09:37:22 +00:00
|
|
|
<ScreenHeader>
|
2022-04-15 14:24:30 +00:00
|
|
|
Current Queue
|
2022-04-20 09:37:22 +00:00
|
|
|
<ControlsToggler :showing-controls="showingControls" @toggleControls="toggleControls"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
|
|
<template v-slot:meta>
|
|
|
|
<span v-if="meta.songCount" data-test="list-meta">
|
2022-04-15 17:00:08 +00:00
|
|
|
{{ pluralize(meta.songCount, 'song') }} • {{ meta.totalLength }}
|
2022-04-15 14:24:30 +00:00
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template v-slot:controls>
|
2022-04-20 09:37:22 +00:00
|
|
|
<SongListControls
|
|
|
|
v-if="songs.length && (!isPhone || showingControls)"
|
2022-04-15 14:24:30 +00:00
|
|
|
@playAll="playAll"
|
|
|
|
@playSelected="playSelected"
|
|
|
|
@clearQueue="clearQueue"
|
2022-04-20 09:37:22 +00:00
|
|
|
:songs="songs"
|
2022-04-15 14:24:30 +00:00
|
|
|
:config="songListControlConfig"
|
|
|
|
:selectedSongs="selectedSongs"
|
|
|
|
/>
|
|
|
|
</template>
|
2022-04-20 09:37:22 +00:00
|
|
|
</ScreenHeader>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-20 09:37:22 +00:00
|
|
|
<SongList
|
|
|
|
v-if="songs.length"
|
|
|
|
:items="songs"
|
2022-04-15 14:24:30 +00:00
|
|
|
:config="{ sortable: false }"
|
|
|
|
type="queue"
|
|
|
|
ref="songList"
|
|
|
|
/>
|
|
|
|
|
2022-04-20 09:37:22 +00:00
|
|
|
<ScreenPlaceholder v-else>
|
2022-04-15 14:24:30 +00:00
|
|
|
<template v-slot:icon>
|
|
|
|
<i class="fa fa-coffee"></i>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
No songs queued.
|
|
|
|
<span class="secondary d-block" v-if="shouldShowShufflingAllLink">
|
|
|
|
How about
|
|
|
|
<a class="start" @click.prevent="shuffleAll">shuffling all songs</a>?
|
|
|
|
</span>
|
2022-04-20 09:37:22 +00:00
|
|
|
</ScreenPlaceholder>
|
2022-04-15 14:24:30 +00:00
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-04-15 14:24:30 +00:00
|
|
|
import { pluralize } from '@/utils'
|
|
|
|
import { queueStore, songStore } from '@/stores'
|
|
|
|
import { playback } from '@/services'
|
2022-04-15 17:00:08 +00:00
|
|
|
import { useSongList } from '@/composables'
|
2022-04-20 09:37:22 +00:00
|
|
|
import { computed, defineAsyncComponent, reactive, toRef } from 'vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const ScreenHeader = defineAsyncComponent(() => import('@/components/ui/screen-header.vue'))
|
|
|
|
const ScreenPlaceholder = defineAsyncComponent(() => import('@/components/ui/screen-placeholder.vue'))
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const {
|
|
|
|
SongList,
|
|
|
|
SongListControls,
|
|
|
|
ControlsToggler,
|
|
|
|
songList,
|
|
|
|
meta,
|
|
|
|
selectedSongs,
|
|
|
|
showingControls,
|
|
|
|
songListControlConfig,
|
|
|
|
isPhone,
|
|
|
|
playSelected,
|
|
|
|
toggleControls
|
|
|
|
} = useSongList({
|
|
|
|
clearQueue: true
|
|
|
|
})
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-20 09:37:22 +00:00
|
|
|
const songs = toRef(queueStore.state, 'songs')
|
2022-04-15 17:00:08 +00:00
|
|
|
const songState = reactive(songStore.state)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const shouldShowShufflingAllLink = computed(() => songState.songs.length > 0)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const playAll = () => {
|
2022-04-20 09:37:22 +00:00
|
|
|
playback.queueAndPlay(songs.value.length ? songList.value.getAllSongsWithSort() : songStore.all)
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const shuffleAll = async () => await playback.queueAndPlay(songStore.all, true)
|
|
|
|
const clearQueue = () => queueStore.clear()
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|