add playlists radio to search result page

This commit is contained in:
petitminion 2022-11-20 10:49:23 +00:00
commit 01fd1503c9
6 changed files with 38 additions and 14 deletions

View file

@ -47,6 +47,10 @@ const buttonLabel = computed(() => {
return running.value
? $pgettext('*/Player/Button.Label/Short, Verb', 'Stop artists radio')
: $pgettext('*/Player/Button.Label/Short, Verb', 'Start artists radio')
case 'playlist':
return running.value
? $pgettext('*/Player/Button.Label/Short, Verb', 'Stop playlists radio')
: $pgettext('*/Player/Button.Label/Short, Verb', 'Start playlists radio')
default:
return running.value
? $pgettext('*/Player/Button.Label/Short, Verb', 'Stop radio')

View file

@ -30,7 +30,7 @@ export interface CurrentRadio {
objectId: ObjectId | null
}
export type RadioConfig = { type: 'tag', names: string[] } | { type: 'artist', ids: string[] }
export type RadioConfig = { type: 'tag', names: string[] } | { type: 'artist' | 'playlist', ids: string[] }
const logger = useLogger()

View file

@ -191,18 +191,19 @@ const labels = computed(() => ({
const radioConfig = computed(() => {
const results = Object.values(currentResults.value?.results ?? {})
if (results.length) {
if (currentType.value?.id === 'tags') {
return {
type: 'tag',
names: results.map(({ name }) => name)
} as RadioConfig
}
switch (currentType.value?.id) {
case 'tags':
return {
type: 'tag',
names: results.map(({ name }) => name)
} as RadioConfig
if (currentType.value?.id === 'artists') {
return {
type: 'artist',
ids: results.map(({ id }) => id)
} as RadioConfig
case 'playlists':
case 'artists':
return {
type: currentType.value.id.slice(0, -1),
ids: results.map(({ id }) => id)
} as RadioConfig
}
// TODO (wvffle): Use logger