2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
2024-04-04 22:20:42 +00:00
|
|
|
<ScreenBase>
|
|
|
|
<template #header>
|
|
|
|
<ScreenHeader :layout="songs.length === 0 ? 'collapsed' : headerLayout">
|
2024-05-19 05:49:42 +00:00
|
|
|
Your Favorites
|
2024-04-04 22:20:42 +00:00
|
|
|
<ControlsToggle v-model="showingControls" />
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2024-04-04 22:20:42 +00:00
|
|
|
<template #thumbnail>
|
|
|
|
<ThumbnailStack :thumbnails="thumbnails" />
|
|
|
|
</template>
|
2022-07-16 09:52:39 +00:00
|
|
|
|
2024-04-04 22:20:42 +00:00
|
|
|
<template v-if="songs.length" #meta>
|
2024-05-19 05:49:42 +00:00
|
|
|
<span>{{ pluralize(songs, 'item') }}</span>
|
2024-04-04 22:20:42 +00:00
|
|
|
<span>{{ duration }}</span>
|
2022-07-10 17:15:56 +00:00
|
|
|
|
2024-04-04 22:20:42 +00:00
|
|
|
<a
|
2024-08-29 17:54:58 +00:00
|
|
|
v-if="downloadable"
|
2024-04-04 22:20:42 +00:00
|
|
|
class="download"
|
|
|
|
role="button"
|
2024-08-29 17:54:58 +00:00
|
|
|
title="Download all favorites"
|
2024-04-04 22:20:42 +00:00
|
|
|
@click.prevent="download"
|
|
|
|
>
|
|
|
|
Download All
|
|
|
|
</a>
|
|
|
|
</template>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2024-04-04 22:20:42 +00:00
|
|
|
<template #controls>
|
|
|
|
<SongListControls
|
|
|
|
v-if="songs.length && (!isPhone || showingControls)"
|
|
|
|
:config="config"
|
|
|
|
@filter="applyFilter"
|
|
|
|
@play-all="playAll"
|
|
|
|
@play-selected="playSelected"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
</ScreenHeader>
|
|
|
|
</template>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2024-04-04 22:20:42 +00:00
|
|
|
<SongListSkeleton v-if="loading" class="-m-6" />
|
2022-04-21 18:12:11 +00:00
|
|
|
<SongList
|
2022-07-12 08:37:11 +00:00
|
|
|
v-if="songs.length"
|
2022-04-21 18:12:11 +00:00
|
|
|
ref="songList"
|
2024-04-04 22:20:42 +00:00
|
|
|
class="-m-6"
|
2022-04-21 18:12:11 +00:00
|
|
|
@press:delete="removeSelected"
|
|
|
|
@press:enter="onPressEnter"
|
2022-07-16 09:52:39 +00:00
|
|
|
@scroll-breakpoint="onScrollBreakpoint"
|
2022-04-21 18:12:11 +00:00
|
|
|
/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-12 08:37:11 +00:00
|
|
|
<ScreenEmptyState v-else>
|
2022-12-02 16:17:37 +00:00
|
|
|
<template #icon>
|
2023-11-10 13:16:06 +00:00
|
|
|
<Icon :icon="faHeartBroken" />
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
No favorites yet.
|
|
|
|
<span class="secondary d-block">
|
2022-04-21 16:06:45 +00:00
|
|
|
Click the
|
2023-11-10 13:16:06 +00:00
|
|
|
<Icon :icon="faHeart" />
|
2022-04-15 14:24:30 +00:00
|
|
|
icon to mark a song as favorite.
|
|
|
|
</span>
|
2022-04-21 18:12:11 +00:00
|
|
|
</ScreenEmptyState>
|
2024-04-04 22:20:42 +00:00
|
|
|
</ScreenBase>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-07-15 07:23:55 +00:00
|
|
|
import { faHeartBroken } from '@fortawesome/free-solid-svg-icons'
|
|
|
|
import { faHeart } from '@fortawesome/free-regular-svg-icons'
|
2022-09-12 15:33:41 +00:00
|
|
|
import { pluralize } from '@/utils'
|
2024-08-29 17:54:58 +00:00
|
|
|
import { favoriteStore } from '@/stores'
|
2022-04-24 08:50:45 +00:00
|
|
|
import { downloadService } from '@/services'
|
2024-01-18 11:13:05 +00:00
|
|
|
import { useRouter, useSongList, useSongListControls } from '@/composables'
|
2024-08-29 17:54:58 +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'
|
2024-04-04 22:20:42 +00:00
|
|
|
import ScreenBase from '@/components/screens/ScreenBase.vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const {
|
|
|
|
SongList,
|
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-04-23 21:24:02 +00:00
|
|
|
duration,
|
2024-08-29 17:54:58 +00:00
|
|
|
downloadable,
|
2022-07-16 09:52:39 +00:00
|
|
|
thumbnails,
|
2024-05-19 05:49:42 +00:00
|
|
|
selectedPlayables,
|
2022-04-15 17:00:08 +00:00
|
|
|
showingControls,
|
|
|
|
isPhone,
|
2022-04-21 18:12:11 +00:00
|
|
|
onPressEnter,
|
2022-04-15 17:00:08 +00:00
|
|
|
playAll,
|
|
|
|
playSelected,
|
2022-12-17 12:09:22 +00:00
|
|
|
applyFilter,
|
2024-08-29 17:54:58 +00:00
|
|
|
onScrollBreakpoint
|
2024-06-02 17:15:31 +00:00
|
|
|
} = useSongList(toRef(favoriteStore.state, 'playables'), { type: 'Favorites' })
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2024-01-18 11:13:05 +00:00
|
|
|
const { SongListControls, config } = useSongListControls('Favorites')
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const download = () => downloadService.fromFavorites()
|
2024-05-19 05:49:42 +00:00
|
|
|
const removeSelected = () => selectedPlayables.value.length && favoriteStore.unlike(selectedPlayables.value)
|
2022-06-10 10:47:46 +00:00
|
|
|
|
|
|
|
let initialized = false
|
2022-07-30 15:08:20 +00:00
|
|
|
const loading = ref(false)
|
2022-06-10 10:47:46 +00:00
|
|
|
|
|
|
|
const fetchSongs = async () => {
|
2022-07-30 15:08:20 +00:00
|
|
|
loading.value = true
|
2022-06-10 10:47:46 +00:00
|
|
|
await favoriteStore.fetch()
|
2022-07-30 15:08:20 +00:00
|
|
|
loading.value = false
|
2022-06-10 10:47:46 +00:00
|
|
|
}
|
|
|
|
|
2022-11-18 18:56:21 +00:00
|
|
|
useRouter().onScreenActivated('Favorites', async () => {
|
2022-09-12 15:33:41 +00:00
|
|
|
if (!initialized) {
|
2022-06-10 10:47:46 +00:00
|
|
|
initialized = true
|
2022-09-12 15:33:41 +00:00
|
|
|
await fetchSongs()
|
2022-06-10 10:47:46 +00:00
|
|
|
}
|
|
|
|
})
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|