2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
2022-10-08 10:54:25 +00:00
|
|
|
<ContextMenuBase ref="base" data-testid="artist-context-menu" extra-class="artist-menu">
|
2022-04-15 14:24:30 +00:00
|
|
|
<template v-if="artist">
|
2022-11-29 10:18:58 +00:00
|
|
|
<li @click="play">Play All</li>
|
|
|
|
<li @click="shuffle">Shuffle All</li>
|
2022-04-15 14:24:30 +00:00
|
|
|
<template v-if="isStandardArtist">
|
2022-12-02 16:17:37 +00:00
|
|
|
<li class="separator" />
|
2022-11-29 10:18:58 +00:00
|
|
|
<li @click="viewArtistDetails">Go to Artist</li>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
2022-04-25 16:13:18 +00:00
|
|
|
<template v-if="isStandardArtist && allowDownload">
|
2022-12-02 16:17:37 +00:00
|
|
|
<li class="separator" />
|
2022-11-29 10:18:58 +00:00
|
|
|
<li @click="download">Download</li>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
</template>
|
2022-04-24 08:29:14 +00:00
|
|
|
</ContextMenuBase>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-07-08 10:32:44 +00:00
|
|
|
import { computed, ref, toRef } from 'vue'
|
2022-06-10 10:47:46 +00:00
|
|
|
import { artistStore, commonStore, songStore } from '@/stores'
|
2022-04-24 08:50:45 +00:00
|
|
|
import { downloadService, playbackService } from '@/services'
|
2022-11-18 18:44:20 +00:00
|
|
|
import { useContextMenu, useRouter } from '@/composables'
|
|
|
|
import { eventBus } from '@/utils'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-11-18 18:44:20 +00:00
|
|
|
const { go } = useRouter()
|
2022-12-02 16:17:37 +00:00
|
|
|
const { base, ContextMenuBase, open, trigger } = useContextMenu()
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-08 10:32:44 +00:00
|
|
|
const artist = ref<Artist>()
|
2024-01-04 11:35:36 +00:00
|
|
|
const allowDownload = toRef(commonStore.state, 'allows_download')
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const isStandardArtist = computed(() =>
|
2022-10-08 10:54:25 +00:00
|
|
|
!artistStore.isUnknown(artist.value!)
|
|
|
|
&& !artistStore.isVarious(artist.value!)
|
2022-04-15 17:00:08 +00:00
|
|
|
)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-10-08 10:54:25 +00:00
|
|
|
const play = () => trigger(async () => {
|
2022-10-21 20:06:43 +00:00
|
|
|
playbackService.queueAndPlay(await songStore.fetchForArtist(artist.value!))
|
2022-11-18 18:44:20 +00:00
|
|
|
go('queue')
|
2022-10-08 10:54:25 +00:00
|
|
|
})
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-10-08 10:54:25 +00:00
|
|
|
const shuffle = () => trigger(async () => {
|
2022-10-21 20:06:43 +00:00
|
|
|
playbackService.queueAndPlay(await songStore.fetchForArtist(artist.value!), true)
|
2022-11-18 18:44:20 +00:00
|
|
|
go('queue')
|
2022-10-08 10:54:25 +00:00
|
|
|
})
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-11-18 18:44:20 +00:00
|
|
|
const viewArtistDetails = () => trigger(() => go(`artist/${artist.value!.id}`))
|
2022-10-08 10:54:25 +00:00
|
|
|
const download = () => trigger(() => downloadService.fromArtist(artist.value!))
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-11-15 15:52:38 +00:00
|
|
|
eventBus.on('ARTIST_CONTEXT_MENU_REQUESTED', async (e, _artist) => {
|
2022-07-08 10:32:44 +00:00
|
|
|
artist.value = _artist
|
2022-12-02 16:17:37 +00:00
|
|
|
await open(e.pageY, e.pageX)
|
2022-07-08 10:32:44 +00:00
|
|
|
})
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|