2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<section id="recentlyPlayedWrapper">
|
2022-07-17 08:58:05 +00:00
|
|
|
<ScreenHeader :layout="songs.length === 0 ? 'collapsed' : headerLayout">
|
2022-04-15 14:24:30 +00:00
|
|
|
Recently Played
|
2022-09-11 08:06:34 +00:00
|
|
|
<ControlsToggle v-model="showingControls"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-16 09:52:39 +00:00
|
|
|
<template v-slot:thumbnail>
|
|
|
|
<ThumbnailStack :thumbnails="thumbnails"/>
|
|
|
|
</template>
|
|
|
|
|
2022-07-10 17:15:56 +00:00
|
|
|
<template v-slot:meta v-if="songs.length">
|
2022-09-03 08:32:09 +00:00
|
|
|
<span>{{ pluralize(songs, 'song') }}</span>
|
2022-07-10 17:15:56 +00:00
|
|
|
<span>{{ duration }}</span>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<template v-slot:controls>
|
2022-04-15 17:00:08 +00:00
|
|
|
<SongListControls
|
2022-04-21 16:06:45 +00:00
|
|
|
v-if="songs.length && (!isPhone || showingControls)"
|
|
|
|
@playAll="playAll"
|
|
|
|
@playSelected="playSelected"
|
2022-04-15 14:24:30 +00:00
|
|
|
/>
|
|
|
|
</template>
|
2022-04-15 17:00:08 +00:00
|
|
|
</ScreenHeader>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-30 15:08:20 +00:00
|
|
|
<SongListSkeleton v-if="loading"/>
|
2022-07-16 09:52:39 +00:00
|
|
|
<SongList v-if="songs.length" ref="songList" @press:enter="onPressEnter" @scroll-breakpoint="onScrollBreakpoint"/>
|
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>
|
2022-07-15 07:23:55 +00:00
|
|
|
<icon :icon="faClock"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
No songs recently played.
|
2022-04-21 16:06:45 +00:00
|
|
|
<span class="secondary d-block">Start playing to populate this playlist.</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-07-15 07:23:55 +00:00
|
|
|
import { faClock } from '@fortawesome/free-regular-svg-icons'
|
2022-04-15 14:24:30 +00:00
|
|
|
import { eventBus, pluralize } from '@/utils'
|
|
|
|
import { recentlyPlayedStore } from '@/stores'
|
2022-04-15 17:00:08 +00:00
|
|
|
import { useSongList } from '@/composables'
|
2022-07-30 15:08:20 +00:00
|
|
|
import { ref, toRef } from 'vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-07 18:05:46 +00:00
|
|
|
import ScreenHeader from '@/components/ui/ScreenHeader.vue'
|
|
|
|
import ScreenEmptyState from '@/components/ui/ScreenEmptyState.vue'
|
2022-07-30 15:08:20 +00:00
|
|
|
import SongListSkeleton from '@/components/ui/skeletons/SongListSkeleton.vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-16 09:52:39 +00:00
|
|
|
const recentlyPlayedSongs = toRef(recentlyPlayedStore.state, 'songs')
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const {
|
|
|
|
SongList,
|
|
|
|
SongListControls,
|
2022-06-10 10:47:46 +00:00
|
|
|
ControlsToggle,
|
2022-07-16 09:52:39 +00:00
|
|
|
ThumbnailStack,
|
|
|
|
headerLayout,
|
2022-04-21 16:06:45 +00:00
|
|
|
songs,
|
2022-04-15 17:00:08 +00:00
|
|
|
songList,
|
2022-07-16 09:52:39 +00:00
|
|
|
thumbnails,
|
2022-04-23 21:24:02 +00:00
|
|
|
duration,
|
2022-04-15 17:00:08 +00:00
|
|
|
showingControls,
|
|
|
|
isPhone,
|
2022-04-21 18:12:11 +00:00
|
|
|
onPressEnter,
|
|
|
|
playAll,
|
2022-04-15 17:00:08 +00:00
|
|
|
playSelected,
|
2022-07-16 09:52:39 +00:00
|
|
|
onScrollBreakpoint
|
|
|
|
} = useSongList(recentlyPlayedSongs, 'recently-played', { sortable: false })
|
2022-06-10 10:47:46 +00:00
|
|
|
|
|
|
|
let initialized = false
|
2022-07-30 15:08:20 +00:00
|
|
|
let loading = ref(false)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
eventBus.on({
|
2022-09-12 11:11:56 +00:00
|
|
|
ACTIVATE_SCREEN: async (screen: ScreenName) => {
|
|
|
|
if (screen === 'RecentlyPlayed' && !initialized) {
|
2022-07-30 15:08:20 +00:00
|
|
|
loading.value = true
|
2022-06-10 10:47:46 +00:00
|
|
|
await recentlyPlayedStore.fetch()
|
2022-07-30 15:08:20 +00:00
|
|
|
loading.value = false
|
2022-06-10 10:47:46 +00:00
|
|
|
initialized = true
|
|
|
|
}
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
})
|
|
|
|
</script>
|