mirror of
https://github.com/koel/koel
synced 2024-12-28 05:23:05 +00:00
117 lines
3.1 KiB
Vue
117 lines
3.1 KiB
Vue
<template>
|
|
<ScreenBase>
|
|
<template #header>
|
|
<ScreenHeader :layout="songs.length === 0 ? 'collapsed' : headerLayout">
|
|
Your Favorites
|
|
<ControlsToggle v-model="showingControls" />
|
|
|
|
<template #thumbnail>
|
|
<ThumbnailStack :thumbnails="thumbnails" />
|
|
</template>
|
|
|
|
<template v-if="songs.length" #meta>
|
|
<span>{{ pluralize(songs, 'item') }}</span>
|
|
<span>{{ duration }}</span>
|
|
|
|
<a
|
|
v-if="downloadable"
|
|
class="download"
|
|
role="button"
|
|
title="Download all favorites"
|
|
@click.prevent="download"
|
|
>
|
|
Download All
|
|
</a>
|
|
</template>
|
|
|
|
<template #controls>
|
|
<SongListControls
|
|
v-if="songs.length && (!isPhone || showingControls)"
|
|
:config="config"
|
|
@filter="applyFilter"
|
|
@play-all="playAll"
|
|
@play-selected="playSelected"
|
|
/>
|
|
</template>
|
|
</ScreenHeader>
|
|
</template>
|
|
|
|
<SongListSkeleton v-if="loading" class="-m-6" />
|
|
<SongList
|
|
v-if="songs.length"
|
|
ref="songList"
|
|
class="-m-6"
|
|
@press:delete="removeSelected"
|
|
@press:enter="onPressEnter"
|
|
@scroll-breakpoint="onScrollBreakpoint"
|
|
/>
|
|
|
|
<ScreenEmptyState v-else>
|
|
<template #icon>
|
|
<Icon :icon="faHeartBroken" />
|
|
</template>
|
|
No favorites yet.
|
|
<span class="secondary d-block">
|
|
Click the
|
|
<Icon :icon="faHeart" />
|
|
icon to mark a song as favorite.
|
|
</span>
|
|
</ScreenEmptyState>
|
|
</ScreenBase>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { faHeartBroken } from '@fortawesome/free-solid-svg-icons'
|
|
import { faHeart } from '@fortawesome/free-regular-svg-icons'
|
|
import { pluralize } from '@/utils'
|
|
import { favoriteStore } from '@/stores'
|
|
import { downloadService } from '@/services'
|
|
import { useRouter, useSongList, useSongListControls } from '@/composables'
|
|
import { ref, toRef } from 'vue'
|
|
|
|
import ScreenHeader from '@/components/ui/ScreenHeader.vue'
|
|
import ScreenEmptyState from '@/components/ui/ScreenEmptyState.vue'
|
|
import SongListSkeleton from '@/components/ui/skeletons/SongListSkeleton.vue'
|
|
import ScreenBase from '@/components/screens/ScreenBase.vue'
|
|
|
|
const {
|
|
SongList,
|
|
ControlsToggle,
|
|
ThumbnailStack,
|
|
headerLayout,
|
|
songs,
|
|
songList,
|
|
duration,
|
|
downloadable,
|
|
thumbnails,
|
|
selectedPlayables,
|
|
showingControls,
|
|
isPhone,
|
|
onPressEnter,
|
|
playAll,
|
|
playSelected,
|
|
applyFilter,
|
|
onScrollBreakpoint
|
|
} = useSongList(toRef(favoriteStore.state, 'playables'), { type: 'Favorites' })
|
|
|
|
const { SongListControls, config } = useSongListControls('Favorites')
|
|
|
|
const download = () => downloadService.fromFavorites()
|
|
const removeSelected = () => selectedPlayables.value.length && favoriteStore.unlike(selectedPlayables.value)
|
|
|
|
let initialized = false
|
|
const loading = ref(false)
|
|
|
|
const fetchSongs = async () => {
|
|
loading.value = true
|
|
await favoriteStore.fetch()
|
|
loading.value = false
|
|
}
|
|
|
|
useRouter().onScreenActivated('Favorites', async () => {
|
|
if (!initialized) {
|
|
initialized = true
|
|
await fetchSongs()
|
|
}
|
|
})
|
|
</script>
|