feat(ui): add Play Artist's Top Songs button (#4204)
* ui: add Play button to artist toolbar * refactor Signed-off-by: Deluan <deluan@navidrome.org> * test(ui): add tests for Play button functionality in ArtistActions Signed-off-by: Deluan <deluan@navidrome.org> * ui: update Play button label to Top Songs in ArtistActions Signed-off-by: Deluan <deluan@navidrome.org> --------- Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -3,4 +3,3 @@ export * from './intersperse'
|
||||
export * from './notifications'
|
||||
export * from './openInNewTab'
|
||||
export * from './urls'
|
||||
export * from './playSimilar'
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import subsonic from '../subsonic'
|
||||
import { playTracks } from '../actions'
|
||||
|
||||
export const playSimilar = async (dispatch, notify, id) => {
|
||||
const res = await subsonic.getSimilarSongs2(id, 100)
|
||||
const data = res.json['subsonic-response']
|
||||
|
||||
if (data.status !== 'ok') {
|
||||
throw new Error(
|
||||
`Error fetching similar songs: ${data.error?.message || 'Unknown error'} (Code: ${data.error?.code || 'unknown'})`,
|
||||
)
|
||||
}
|
||||
|
||||
const songs = data.similarSongs2?.song || []
|
||||
if (!songs.length) {
|
||||
notify('message.noSimilarSongsFound', 'warning')
|
||||
return
|
||||
}
|
||||
|
||||
const songData = {}
|
||||
const ids = []
|
||||
songs.forEach((s) => {
|
||||
songData[s.id] = s
|
||||
ids.push(s.id)
|
||||
})
|
||||
dispatch(playTracks(songData, ids))
|
||||
}
|
||||
Reference in New Issue
Block a user