mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 22:45:41 +00:00
fix(artist-info): id-gate fetchers, share ArtistCard, square hero (#739)
* fix(artist-info): id-gate fetcher tuples, reuse ArtistCard on ArtistDetail The cache-mismatch bug PR #732 fixed in `NowPlayingInfo.tsx` had the same shape inside `ArtistCard` on the NowPlaying page: `useNowPlayingFetchers` returned `artistInfo` for the previously-current artist for one render after `artistId` changed, and `CachedImage` persisted that mismatched blob under the new `artistInfo:<new-id>:hero` key in IndexedDB — sticky "previous artist" image on every subsequent track. Apply the same `{ id, value }` tuple pattern from PR #732 inside the hooks themselves so every consumer is safe by construction: - `useNowPlayingFetchers`: gate `artistInfo`, `songMeta`, `albumData`, `discography` on id-match at the return. Late-arriving resolves for a stale id can no longer overwrite the displayed value. - `useArtistDetailData`: same for `info`. Required because the `ArtistDetail` bio card now uses `CachedImage` via the shared `ArtistCard` (previously raw `<img>`, no persistence hazard). Unify `ArtistDetail`'s inline "About the Artist" block onto the same shared `ArtistCard` so there is one source of truth for hero / bio / similar rendering. New optional props: `onNavigate?` (omitted on `/artist/:id` since the user is already there), `coverFallback` (coverArt fallback when artistInfo has no hero image), `hideArtistName` (avoid duplicating the hero name), `hideSimilar` (ArtistDetail has its own similar-artists section). Tests cover the gating contract for both hooks (incl. stale-resolve race) and the `ArtistCard` prop matrix. * fix(artist-image): square queue info hero, drop artist-avatar glow - Queue Info bar's artist hero was rendered in a 16:10 wrap with `object-fit: cover`, so portrait photos lost top/bottom equally while landscape ones lost the sides — perceived as cropped even on roughly square sources. Set the wrap to 1:1 so the crop is symmetric and matches the typical square framing of artist photography. - `ArtistDetail` extracted the cover's accent colour on every image load and rendered a 36px / 8px-spread `boxShadow` ring around the avatar. Drop the glow, the state, the one-shot reset effect, the prop-passing through `ArtistDetailHero`, and the now-orphaned `extractCoverColors` import on this page. `extractCoverColors` itself stays in place (still used by `useFsDynamicAccent`). * docs(changelog): artist-info image fix extension + UI tweaks (PR #739)
This commit is contained in:
committed by
GitHub
parent
97957df310
commit
6cc227d761
@@ -10,7 +10,6 @@ import { useOfflineStore } from '../../store/offlineStore';
|
||||
import { useOfflineJobStore } from '../../store/offlineJobStore';
|
||||
import { useAuthStore } from '../../store/authStore';
|
||||
import { useIsMobile } from '../../hooks/useIsMobile';
|
||||
import { extractCoverColors } from '../../utils/ui/dynamicColors';
|
||||
import CachedImage from '../CachedImage';
|
||||
import CoverLightbox from '../CoverLightbox';
|
||||
import LastfmIcon from '../LastfmIcon';
|
||||
@@ -42,8 +41,6 @@ interface Props {
|
||||
coverRevision: number;
|
||||
headerCoverFailed: boolean;
|
||||
setHeaderCoverFailed: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
avatarGlow: string;
|
||||
setAvatarGlow: React.Dispatch<React.SetStateAction<string>>;
|
||||
lightboxOpen: boolean;
|
||||
setLightboxOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
}
|
||||
@@ -55,7 +52,7 @@ export default function ArtistDetailHero({
|
||||
openedLink, openLink,
|
||||
coverId, artistCover300Src, artistCover300Key, artistCover2000Src,
|
||||
coverRevision, headerCoverFailed, setHeaderCoverFailed,
|
||||
avatarGlow, setAvatarGlow, lightboxOpen, setLightboxOpen,
|
||||
lightboxOpen, setLightboxOpen,
|
||||
}: Props) {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
@@ -88,14 +85,7 @@ export default function ArtistDetailHero({
|
||||
)}
|
||||
|
||||
<div className="artist-detail-header">
|
||||
<div
|
||||
className="artist-detail-avatar"
|
||||
style={{
|
||||
position: 'relative',
|
||||
boxShadow: avatarGlow ? `0 0 36px 8px ${avatarGlow.replace('rgb(', 'rgba(').replace(')', ', 0.55)')}` : undefined,
|
||||
transition: 'box-shadow 0.6s ease',
|
||||
}}
|
||||
>
|
||||
<div className="artist-detail-avatar" style={{ position: 'relative' }}>
|
||||
{coverId ? (
|
||||
<button
|
||||
className="artist-detail-avatar-btn"
|
||||
@@ -109,7 +99,6 @@ export default function ArtistDetailHero({
|
||||
cacheKey={artistCover300Key}
|
||||
alt={artist.name}
|
||||
style={{ width: '100%', height: '100%', objectFit: 'cover' }}
|
||||
onLoad={e => extractCoverColors(e.currentTarget.src).then(({ accent }) => { if (accent) setAvatarGlow(accent); })}
|
||||
onError={() => setHeaderCoverFailed(true)}
|
||||
/>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user