2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<section id="artistWrapper">
|
2022-04-21 10:18:11 +00:00
|
|
|
<ScreenHeader has-thumbnail>
|
2022-04-15 14:24:30 +00:00
|
|
|
{{ artist.name }}
|
2022-06-10 10:47:46 +00:00
|
|
|
<ControlsToggle :showing-controls="showingControls" @toggleControls="toggleControls"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
|
|
<template v-slot:thumbnail>
|
2022-04-15 17:00:08 +00:00
|
|
|
<ArtistThumbnail :entity="artist"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<template v-slot:meta>
|
2022-04-21 16:06:45 +00:00
|
|
|
<span v-if="songs.length">
|
2022-06-10 10:47:46 +00:00
|
|
|
{{ pluralize(artist.album_count, 'album') }}
|
2022-04-15 14:24:30 +00:00
|
|
|
•
|
2022-04-21 16:06:45 +00:00
|
|
|
{{ pluralize(songs.length, 'song') }}
|
2022-04-15 14:24:30 +00:00
|
|
|
•
|
2022-04-23 21:24:02 +00:00
|
|
|
{{ duration }}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-25 16:13:18 +00:00
|
|
|
<template v-if="useLastfm">
|
2022-04-15 14:24:30 +00:00
|
|
|
•
|
2022-04-21 16:06:45 +00:00
|
|
|
<a class="info" href title="View artist's extra information" @click.prevent="showInfo">Info</a>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
2022-04-25 16:13:18 +00:00
|
|
|
<template v-if="allowDownload">
|
2022-04-15 14:24:30 +00:00
|
|
|
•
|
|
|
|
<a
|
|
|
|
class="download"
|
|
|
|
href
|
|
|
|
role="button"
|
|
|
|
title="Download all songs by this artist"
|
2022-04-21 16:06:45 +00:00
|
|
|
@click.prevent="download"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
|
|
|
Download All
|
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
</span>
|
|
|
|
</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-06-10 10:47:46 +00:00
|
|
|
<SongList ref="songList" @press:enter="onPressEnter"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
<section class="info-wrapper" v-if="useLastfm && showingInfo">
|
|
|
|
<CloseModalBtn @click="showingInfo = false"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
<div class="inner">
|
2022-06-10 10:47:46 +00:00
|
|
|
<ArtistInfo :artist="artist" mode="full"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-06-10 10:47:46 +00:00
|
|
|
import { defineAsyncComponent, onMounted, ref, toRef, toRefs, watch } from 'vue'
|
2022-07-04 13:24:02 +00:00
|
|
|
import { eventBus, pluralize } from '@/utils'
|
|
|
|
import { artistStore, commonStore, songStore } from '@/stores'
|
2022-06-10 10:47:46 +00:00
|
|
|
import { downloadService } from '@/services'
|
2022-04-30 14:05:02 +00:00
|
|
|
import { useSongList, useThirdPartyServices } from '@/composables'
|
2022-04-15 14:24:30 +00:00
|
|
|
import router from '@/router'
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-07-07 18:05:46 +00:00
|
|
|
import ScreenHeader from '@/components/ui/ScreenHeader.vue'
|
|
|
|
import ArtistThumbnail from '@/components/ui/AlbumArtistThumbnail.vue'
|
|
|
|
|
2022-04-21 16:06:45 +00:00
|
|
|
const props = defineProps<{ artist: Artist }>()
|
|
|
|
const { artist } = toRefs(props)
|
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
const artistSongs = ref<Song[]>([])
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const {
|
|
|
|
SongList,
|
|
|
|
SongListControls,
|
2022-06-10 10:47:46 +00:00
|
|
|
ControlsToggle,
|
2022-04-15 17:00:08 +00:00
|
|
|
songList,
|
2022-04-21 16:06:45 +00:00
|
|
|
songs,
|
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,
|
2022-04-15 17:00:08 +00:00
|
|
|
playAll,
|
|
|
|
playSelected,
|
|
|
|
toggleControls
|
2022-06-10 10:47:46 +00:00
|
|
|
} = useSongList(artistSongs, 'artist', { columns: ['track', 'title', 'album', 'length'] })
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-04-21 21:51:17 +00:00
|
|
|
const ArtistInfo = defineAsyncComponent(() => import('@/components/artist/ArtistInfo.vue'))
|
2022-04-24 08:29:14 +00:00
|
|
|
const CloseModalBtn = defineAsyncComponent(() => import('@/components/ui/BtnCloseModal.vue'))
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-04-30 14:05:02 +00:00
|
|
|
const { useLastfm } = useThirdPartyServices()
|
2022-06-10 10:47:46 +00:00
|
|
|
const allowDownload = toRef(commonStore.state, 'allow_download')
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
const showingInfo = ref(false)
|
2022-04-15 17:00:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Watch the artist's album count.
|
|
|
|
* If this is changed to 0, the user has edited the songs by this artist
|
|
|
|
* and moved all of them to another artist (thus deleted this artist entirely).
|
|
|
|
* We should then go back to the artist list.
|
|
|
|
*/
|
2022-06-10 10:47:46 +00:00
|
|
|
watch(() => artist.value.album_count, newAlbumCount => newAlbumCount || router.go('artists'))
|
2022-04-15 17:00:08 +00:00
|
|
|
|
|
|
|
const download = () => downloadService.fromArtist(artist.value)
|
2022-06-10 10:47:46 +00:00
|
|
|
const showInfo = () => (showingInfo.value = true)
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
onMounted(async () => {
|
|
|
|
artistSongs.value = await songStore.fetchForArtist(artist.value)
|
|
|
|
})
|
2022-07-04 13:24:02 +00:00
|
|
|
|
|
|
|
eventBus.on('SONGS_UPDATED', () => {
|
|
|
|
// if the current artist has been deleted, go back to home
|
|
|
|
artistStore.byId(artist.value.id) || router.go('home')
|
|
|
|
})
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2022-07-04 15:57:08 +00:00
|
|
|
@import "#/partials/_mixins.scss";
|
|
|
|
|
2022-04-15 14:24:30 +00:00
|
|
|
#artistWrapper {
|
|
|
|
@include artist-album-info-wrapper();
|
|
|
|
}
|
|
|
|
</style>
|