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-06-10 10:47:46 +00:00
|
|
|
<ControlsToggle :showing-controls="showingControls" @toggleControls="toggleControls"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
|
|
<template v-slot:meta>
|
2022-05-10 23:01:48 +00:00
|
|
|
<span v-if="songs.length">
|
2022-04-23 21:24:02 +00:00
|
|
|
{{ pluralize(songs.length, 'song') }} • {{ duration }}
|
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-06-10 10:47:46 +00:00
|
|
|
:config="controlConfig"
|
2022-04-15 14:24:30 +00:00
|
|
|
/>
|
|
|
|
</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"
|
2022-04-21 18:12:11 +00:00
|
|
|
ref="songList"
|
|
|
|
@press:delete="removeSelected"
|
|
|
|
@press:enter="onPressEnter"
|
2022-04-28 16:04:52 +00:00
|
|
|
@reorder="onReorder"
|
2022-04-15 14:24:30 +00:00
|
|
|
/>
|
|
|
|
|
2022-04-21 18:12:11 +00:00
|
|
|
<ScreenEmptyState v-else>
|
2022-04-15 14:24:30 +00:00
|
|
|
<template v-slot:icon>
|
|
|
|
<i class="fa fa-coffee"></i>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
No songs queued.
|
2022-04-27 21:43:00 +00:00
|
|
|
<span class="d-block secondary" v-if="libraryNotEmpty">
|
2022-04-21 18:14:24 +00:00
|
|
|
How about
|
2022-06-10 10:47:46 +00:00
|
|
|
<a data-testid="shuffle-library" class="start" @click.prevent="shuffleSome">playing some random songs</a>?
|
2022-04-21 18:14:24 +00:00
|
|
|
</span>
|
2022-04-21 18:12:11 +00:00
|
|
|
</ScreenEmptyState>
|
2022-04-15 14:24:30 +00:00
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-04-25 16:13:18 +00:00
|
|
|
import { computed, defineAsyncComponent, toRef } from 'vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
import { pluralize } from '@/utils'
|
2022-06-10 10:47:46 +00:00
|
|
|
import { commonStore, queueStore } from '@/stores'
|
2022-04-24 08:50:45 +00:00
|
|
|
import { playbackService } from '@/services'
|
2022-04-15 17:00:08 +00:00
|
|
|
import { useSongList } from '@/composables'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-21 16:06:45 +00:00
|
|
|
const ScreenHeader = defineAsyncComponent(() => import('@/components/ui/ScreenHeader.vue'))
|
2022-04-21 18:12:11 +00:00
|
|
|
const ScreenEmptyState = defineAsyncComponent(() => import('@/components/ui/ScreenEmptyState.vue'))
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
const controlConfig: Partial<SongListControlsConfig> = { clearQueue: true }
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const {
|
|
|
|
SongList,
|
|
|
|
SongListControls,
|
2022-06-10 10:47:46 +00:00
|
|
|
ControlsToggle,
|
2022-04-21 16:06:45 +00:00
|
|
|
songs,
|
2022-04-15 17:00:08 +00:00
|
|
|
songList,
|
2022-04-23 21:24:02 +00:00
|
|
|
duration,
|
2022-04-15 17:00:08 +00:00
|
|
|
selectedSongs,
|
|
|
|
showingControls,
|
|
|
|
isPhone,
|
|
|
|
playSelected,
|
|
|
|
toggleControls
|
2022-06-10 10:47:46 +00:00
|
|
|
} = useSongList(toRef(queueStore.state, 'songs'), 'queue', { sortable: false })
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
const libraryNotEmpty = computed(() => commonStore.state.song_count > 0)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-30 10:36:35 +00:00
|
|
|
const playAll = (shuffle = true) => playbackService.queueAndPlay(songs.value, shuffle)
|
2022-06-10 10:47:46 +00:00
|
|
|
|
|
|
|
const shuffleSome = async () => {
|
|
|
|
await queueStore.fetchRandom()
|
|
|
|
await playbackService.playFirstInQueue()
|
|
|
|
}
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const clearQueue = () => queueStore.clear()
|
2022-04-21 18:12:11 +00:00
|
|
|
const removeSelected = () => selectedSongs.value.length && queueStore.unqueue(selectedSongs.value)
|
2022-04-24 08:50:45 +00:00
|
|
|
const onPressEnter = () => selectedSongs.value.length && playbackService.play(selectedSongs.value[0])
|
2022-04-28 16:04:52 +00:00
|
|
|
const onReorder = (target: Song) => queueStore.move(selectedSongs.value, target)
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
2022-04-21 16:28:12 +00:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.start {
|
|
|
|
color: var(--color-highlight);
|
|
|
|
}
|
|
|
|
</style>
|