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-04-15 17:00:08 +00:00
|
|
|
<ControlsToggler :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-04-15 17:00:08 +00:00
|
|
|
{{ pluralize(artist.albums.length, '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
|
|
|
•
|
|
|
|
{{ fmtLength }}
|
|
|
|
|
|
|
|
<template v-if="sharedState.useLastfm">
|
|
|
|
•
|
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>
|
|
|
|
|
|
|
|
<template v-if="sharedState.allowDownload">
|
|
|
|
•
|
|
|
|
<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)"
|
2022-04-15 14:24:30 +00:00
|
|
|
:config="songListControlConfig"
|
|
|
|
:selectedSongs="selectedSongs"
|
2022-04-21 16:06:45 +00:00
|
|
|
:songs="songs"
|
|
|
|
@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-04-21 18:12:11 +00:00
|
|
|
<SongList ref="songList" :config="listConfig" :items="songs" type="artist" @press:enter="onPressEnter"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<section class="info-wrapper" v-if="sharedState.useLastfm && showing">
|
|
|
|
<CloseModalBtn @click="showing = false"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
<div class="inner">
|
2022-04-15 17:00:08 +00:00
|
|
|
<div class="loading" v-if="loading">
|
|
|
|
<SoundBar/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
2022-04-15 17:00:08 +00:00
|
|
|
<ArtistInfo :artist="artist" mode="full" v-else/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { defineAsyncComponent, reactive, ref, toRefs, watch } from 'vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
import { pluralize } from '@/utils'
|
|
|
|
import { sharedStore } from '@/stores'
|
2022-04-15 17:00:08 +00:00
|
|
|
import { artistInfo as artistInfoService, download as downloadService } from '@/services'
|
2022-04-15 14:24:30 +00:00
|
|
|
import router from '@/router'
|
2022-04-15 17:00:08 +00:00
|
|
|
import { useArtistAttributes, useSongList } from '@/composables'
|
|
|
|
|
2022-04-21 16:06:45 +00:00
|
|
|
const props = defineProps<{ artist: Artist }>()
|
|
|
|
const { artist } = toRefs(props)
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const {
|
|
|
|
SongList,
|
|
|
|
SongListControls,
|
|
|
|
ControlsToggler,
|
|
|
|
songList,
|
2022-04-21 16:06:45 +00:00
|
|
|
songs,
|
2022-04-15 17:00:08 +00:00
|
|
|
meta,
|
|
|
|
selectedSongs,
|
|
|
|
showingControls,
|
|
|
|
songListControlConfig,
|
|
|
|
isPhone,
|
2022-04-21 18:12:11 +00:00
|
|
|
onPressEnter,
|
2022-04-15 17:00:08 +00:00
|
|
|
playAll,
|
|
|
|
playSelected,
|
|
|
|
toggleControls
|
2022-04-21 16:06:45 +00:00
|
|
|
} = useSongList(ref(artist.value.songs))
|
2022-04-15 17:00:08 +00:00
|
|
|
|
|
|
|
const { length, fmtLength, image } = useArtistAttributes(artist.value)
|
|
|
|
|
2022-04-21 16:06:45 +00:00
|
|
|
const ScreenHeader = defineAsyncComponent(() => import('@/components/ui/ScreenHeader.vue'))
|
2022-04-15 17:00:08 +00:00
|
|
|
const ArtistInfo = defineAsyncComponent(() => import('@/components/artist/info.vue'))
|
|
|
|
const SoundBar = defineAsyncComponent(() => import('@/components/ui/sound-bar.vue'))
|
2022-04-21 10:18:11 +00:00
|
|
|
const ArtistThumbnail = defineAsyncComponent(() => import('@/components/ui/AlbumArtistThumbnail.vue'))
|
2022-04-15 17:00:08 +00:00
|
|
|
const CloseModalBtn = defineAsyncComponent(() => import('@/components/ui/close-modal-btn.vue'))
|
|
|
|
|
|
|
|
const listConfig: Partial<SongListConfig> = { columns: ['track', 'title', 'album', 'length'] }
|
|
|
|
const sharedState = reactive(sharedStore.state)
|
|
|
|
|
|
|
|
const showing = ref(false)
|
|
|
|
const loading = ref(true)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
watch(() => artist.value.albums.length, newAlbumCount => newAlbumCount || router.go('artists'))
|
|
|
|
|
|
|
|
watch(artist, () => {
|
|
|
|
showing.value = false
|
|
|
|
songList.value?.sort()
|
|
|
|
})
|
|
|
|
|
|
|
|
const download = () => downloadService.fromArtist(artist.value)
|
|
|
|
|
|
|
|
const showInfo = async () => {
|
|
|
|
showing.value = true
|
|
|
|
|
|
|
|
if (!artist.value.info) {
|
|
|
|
try {
|
|
|
|
await artistInfoService.fetch(artist.value)
|
|
|
|
} catch (e) {
|
|
|
|
/* eslint no-console: 0 */
|
|
|
|
console.error(e)
|
|
|
|
} finally {
|
|
|
|
loading.value = false
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
2022-04-15 17:00:08 +00:00
|
|
|
} else {
|
|
|
|
loading.value = false
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
#artistWrapper {
|
|
|
|
@include artist-album-info-wrapper();
|
|
|
|
}
|
|
|
|
</style>
|