2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<section id="recentlyPlayedWrapper">
|
2022-04-15 17:00:08 +00:00
|
|
|
<ScreenHeader>
|
2022-04-15 14:24:30 +00:00
|
|
|
Recently Played
|
2022-04-15 17:00:08 +00:00
|
|
|
<ControlsToggler :showing-controls="showingControls" @toggleControls="toggleControls"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
|
|
<template v-slot:meta>
|
2022-04-15 17:00:08 +00:00
|
|
|
<span v-if="meta.songCount">{{ pluralize(meta.songCount, 'song') }} • {{ meta.totalLength }}</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-15 14:24:30 +00:00
|
|
|
v-if="state.songs.length && (!isPhone || showingControls)"
|
|
|
|
@playAll="playAll"
|
|
|
|
@playSelected="playSelected"
|
|
|
|
:songs="state.songs"
|
|
|
|
:config="songListControlConfig"
|
|
|
|
:selectedSongs="selectedSongs"
|
|
|
|
/>
|
|
|
|
</template>
|
2022-04-15 17:00:08 +00:00
|
|
|
</ScreenHeader>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<SongList v-if="state.songs.length" :items="state.songs" type="recently-played" :sortable="false"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<ScreenPlaceholder v-else>
|
2022-04-15 14:24:30 +00:00
|
|
|
<template v-slot:icon>
|
|
|
|
<i class="fa fa-clock-o"></i>
|
|
|
|
</template>
|
|
|
|
No songs recently played.
|
|
|
|
<span class="secondary d-block">
|
|
|
|
Start playing to populate this playlist.
|
|
|
|
</span>
|
2022-04-15 17:00:08 +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 { eventBus, pluralize } from '@/utils'
|
|
|
|
import { recentlyPlayedStore } from '@/stores'
|
2022-04-15 17:00:08 +00:00
|
|
|
import { useSongList } from '@/composables'
|
|
|
|
import { defineAsyncComponent, reactive } from 'vue'
|
|
|
|
import { playback } from '@/services'
|
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()
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const state = reactive(recentlyPlayedStore.state)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const playAll = () => playback.queueAndPlay(state.songs)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
eventBus.on({
|
|
|
|
'LOAD_MAIN_CONTENT': (view: MainViewName) => view === 'RecentlyPlayed' && recentlyPlayedStore.fetchAll()
|
2022-04-15 14:24:30 +00:00
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
#recentlyPlayedWrapper {
|
|
|
|
.none {
|
|
|
|
padding: 16px 24px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|