mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 14:35:41 +00:00
fix(now-playing): split artist links and About the Artist tabs (#960)
* fix(now-playing): split artist links and About the Artist tabs OpenSubsonic artists[] now drives per-artist navigation on Now Playing hero and the queue current-track row (matching player bar). About the Artist loads bio for each performer via tabs when a track has multiple artist ids; queue Info uses the primary ref for bio/tour fetch. Reported by zunoz on the Psysonic Discord (v1.47.0-rc.3). * docs: note Now Playing multi-artist fix in CHANGELOG (PR #960)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { primaryTrackArtistRef, resolveTrackArtistRefs } from './trackArtistRefs';
|
||||
|
||||
describe('resolveTrackArtistRefs', () => {
|
||||
it('prefers OpenSubsonic artists[] when present', () => {
|
||||
const refs = [{ id: 'a1', name: 'Dan Balan' }, { id: 'a2', name: 'Katerina Begu' }];
|
||||
expect(resolveTrackArtistRefs({
|
||||
artist: 'Dan Balan feat. Katerina Begu',
|
||||
artistId: 'legacy',
|
||||
artists: refs,
|
||||
})).toEqual(refs);
|
||||
});
|
||||
|
||||
it('falls back to legacy artistId + artist', () => {
|
||||
expect(resolveTrackArtistRefs({
|
||||
artist: 'Solo',
|
||||
artistId: 'ar-solo',
|
||||
})).toEqual([{ id: 'ar-solo', name: 'Solo' }]);
|
||||
});
|
||||
|
||||
it('returns name-only ref when no id', () => {
|
||||
expect(resolveTrackArtistRefs({ artist: 'Unknown' })).toEqual([{ name: 'Unknown' }]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('primaryTrackArtistRef', () => {
|
||||
it('returns the first structured ref', () => {
|
||||
expect(primaryTrackArtistRef({
|
||||
artist: 'A feat. B',
|
||||
artists: [{ id: 'a1', name: 'A' }, { id: 'a2', name: 'B' }],
|
||||
})).toEqual({ id: 'a1', name: 'A' });
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { SubsonicOpenArtistRef } from '../../api/subsonicTypes';
|
||||
import type { Track } from '../../store/playerStoreTypes';
|
||||
|
||||
type TrackArtistFields = Pick<Track, 'artist' | 'artistId' | 'artists'>;
|
||||
|
||||
/** OpenSubsonic `artists` when present; else legacy `artistId` + `artist` (album track rows). */
|
||||
export function resolveTrackArtistRefs(track: TrackArtistFields): SubsonicOpenArtistRef[] {
|
||||
if (track.artists && track.artists.length > 0) {
|
||||
return track.artists;
|
||||
}
|
||||
const id = track.artistId?.trim();
|
||||
if (id) {
|
||||
return [{ id, name: track.artist }];
|
||||
}
|
||||
return [{ name: track.artist }];
|
||||
}
|
||||
|
||||
/** First performer ref — used for artist bio / discography / top songs on Now Playing. */
|
||||
export function primaryTrackArtistRef(track: TrackArtistFields): SubsonicOpenArtistRef {
|
||||
return resolveTrackArtistRefs(track)[0];
|
||||
}
|
||||
Reference in New Issue
Block a user