mirror of
https://github.com/koel/koel
synced 2024-12-20 09:33:23 +00:00
75 lines
1.8 KiB
Vue
75 lines
1.8 KiB
Vue
<template>
|
|
<section id="recentlyPlayedWrapper">
|
|
<ScreenHeader>
|
|
Recently Played
|
|
<ControlsToggle :showing-controls="showingControls" @toggleControls="toggleControls"/>
|
|
|
|
<template v-slot:meta v-if="songs.length">
|
|
<span>{{ pluralize(songs.length, 'song') }}</span>
|
|
<span>{{ duration }}</span>
|
|
</template>
|
|
|
|
<template v-slot:controls>
|
|
<SongListControls
|
|
v-if="songs.length && (!isPhone || showingControls)"
|
|
@playAll="playAll"
|
|
@playSelected="playSelected"
|
|
/>
|
|
</template>
|
|
</ScreenHeader>
|
|
|
|
<SongList v-if="songs.length" ref="songList" @press:enter="onPressEnter"/>
|
|
|
|
<ScreenEmptyState v-else>
|
|
<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>
|
|
</ScreenEmptyState>
|
|
</section>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { eventBus, pluralize } from '@/utils'
|
|
import { recentlyPlayedStore } from '@/stores'
|
|
import { useSongList } from '@/composables'
|
|
import { toRef } from 'vue'
|
|
|
|
import ScreenHeader from '@/components/ui/ScreenHeader.vue'
|
|
import ScreenEmptyState from '@/components/ui/ScreenEmptyState.vue'
|
|
|
|
const {
|
|
SongList,
|
|
SongListControls,
|
|
ControlsToggle,
|
|
songs,
|
|
songList,
|
|
duration,
|
|
showingControls,
|
|
isPhone,
|
|
onPressEnter,
|
|
playAll,
|
|
playSelected,
|
|
toggleControls
|
|
} = useSongList(toRef(recentlyPlayedStore.state, 'songs'), 'recently-played', { sortable: false })
|
|
|
|
let initialized = false
|
|
|
|
eventBus.on({
|
|
'LOAD_MAIN_CONTENT': async (view: MainViewName) => {
|
|
if (view === 'RecentlyPlayed' && !initialized) {
|
|
await recentlyPlayedStore.fetch()
|
|
initialized = true
|
|
}
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
#recentlyPlayedWrapper {
|
|
.none {
|
|
padding: 16px 24px;
|
|
}
|
|
}
|
|
</style>
|