mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 14:35:41 +00:00
fix(playback): pin queue playback to source server when browsing another library (#717)
* fix(playback): pin queue streams, cover art, and library links to queue server When the active server changes while a queue from another server is playing, keep streams and UI on queueServerId; switch back for artist/album links and queue or player-bar context menus. * fix(playback): switch to queue server when opening Now Playing Ensure active server matches queueServerId before Subsonic fetches on the Now Playing page, mobile player route, and queue info panel; scope caches by server id. * docs(credits): mention Now Playing in PR #717 contribution line * fix(playback): route scrobble and queue sync to queue server Address PR review: apiForServer for scrobble/now-playing/savePlayQueue, clear queueServerId on server removal, mini-player queueServerId sync, block cross-server enqueue with toast, and regression tests.
This commit is contained in:
@@ -2,6 +2,7 @@ import axios from 'axios';
|
||||
import md5 from 'md5';
|
||||
import { version } from '../../package.json';
|
||||
import { useAuthStore } from '../store/authStore';
|
||||
import type { ServerProfile } from '../store/authStoreTypes';
|
||||
|
||||
export const SUBSONIC_CLIENT = `psysonic/${version}`;
|
||||
|
||||
@@ -51,6 +52,22 @@ export function getClient() {
|
||||
return { baseUrl: `${baseUrl}/rest`, params };
|
||||
}
|
||||
|
||||
export function getServerById(serverId: string): ServerProfile | undefined {
|
||||
return useAuthStore.getState().servers.find(s => s.id === serverId);
|
||||
}
|
||||
|
||||
/** Subsonic REST call against an explicit saved server (not necessarily the active one). */
|
||||
export async function apiForServer<T>(
|
||||
serverId: string,
|
||||
endpoint: string,
|
||||
extra: Record<string, unknown> = {},
|
||||
timeout = 15000,
|
||||
): Promise<T> {
|
||||
const server = getServerById(serverId);
|
||||
if (!server) throw new Error(`Unknown server: ${serverId}`);
|
||||
return apiWithCredentials(server.url, server.username, server.password, endpoint, extra, timeout);
|
||||
}
|
||||
|
||||
export async function api<T>(endpoint: string, extra: Record<string, unknown> = {}, timeout = 15000): Promise<T> {
|
||||
const { baseUrl, params } = getClient();
|
||||
const resp = await axios.get(`${baseUrl}/${endpoint}`, {
|
||||
|
||||
Reference in New Issue
Block a user