mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
fix(now-playing): keep metadata cards when the track plays from local cache (#1042)
* fix(now-playing): keep metadata cards when the track plays from local cache The Now Playing metadata fetches (album, artist info, discography, top songs) gated on shouldAttemptSubsonicForServer(serverId, trackId). That guard returns false when the current track's audio resolves to a psysonic-local:// URL (hot cache / offline bytes), which is correct for playback-byte calls but wrongly suppressed the metadata calls. On track change the prefetched next track plays from the hot cache, so every Subsonic-backed card blanked and only the Last.fm bio fallback and Bandsintown tour (both non-Subsonic) remained. Drop the trackId from the four Now Playing metadata gates so metadata is fetched whenever the server is reachable, regardless of where the audio bytes come from. True-offline is still handled by the online / reachability checks in the guard. The guard and all other call sites are unchanged. * docs: add CHANGELOG entry for PR #1042 * refactor(now-playing): single Subsonic network gate owned by the fetchers hook The metadata reachability guard (shouldAttemptSubsonicForServer) ran 2-3 times per Now Playing render/effect cycle: callers folded it into fetchEnabled in NowPlaying.tsx and useNowPlayingPrewarm on top of the checks already inside useNowPlayingFetchers and prewarmNowPlayingFetchers. Callers now pass fetchEnabled as intent only ("we have a playback server id"); the single reachability decision lives in the hook / prewarm function. Behaviour is unchanged — only the duplicated guard calls go. * test(now-playing): cover local-playback metadata behaviour, not only call shape Add a guard test proving the metadata gate (no trackId) bypasses the psysonic-local:// skip while a byte-style call stays blocked, and a hook test that fetches album/discography/top songs with a trackId-sensitive guard — so a reintroduced trackId at the gate fails the suite instead of silently blanking the cards.
This commit is contained in:
@@ -6,7 +6,6 @@ import type { SubsonicArtistInfo, SubsonicSong } from '../api/subsonicTypes';
|
||||
import React, { useState, useRef, useEffect, useCallback, useMemo, memo } from 'react';
|
||||
import { usePlaybackLibraryNavigate } from '../hooks/usePlaybackLibraryNavigate';
|
||||
import { usePlaybackServerId } from '../hooks/usePlaybackServerId';
|
||||
import { shouldAttemptSubsonicForServer } from '../utils/network/subsonicNetworkGuard';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Music, ExternalLink, Cast, Users, Radio, Clock, SkipForward, Info, Calendar, Disc3, Play, EyeOff, LayoutGrid, RotateCcw, Eye } from 'lucide-react';
|
||||
import { open as shellOpen } from '@tauri-apps/plugin-shell';
|
||||
@@ -94,8 +93,10 @@ export default function NowPlaying() {
|
||||
enableBandsintown, audiomuseNavidromeEnabled,
|
||||
lastfmUsername, currentTrack,
|
||||
subsonicServerId: playbackServerId,
|
||||
fetchEnabled: Boolean(playbackServerId)
|
||||
&& shouldAttemptSubsonicForServer(playbackServerId, currentTrack?.id),
|
||||
// `fetchEnabled` = "we have a playback server id". The reachability decision
|
||||
// (online / server reachable, no trackId so local-cache playback still loads
|
||||
// metadata) lives in one place inside the hook — see its JSDoc.
|
||||
fetchEnabled: Boolean(playbackServerId),
|
||||
});
|
||||
|
||||
// Star + Last.fm love + their toggle callbacks
|
||||
|
||||
Reference in New Issue
Block a user