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:
+14
-9
@@ -1,4 +1,5 @@
|
||||
import { buildStreamUrl } from './api/subsonicStreamUrl';
|
||||
import { buildStreamUrlForServer } from './api/subsonicStreamUrl';
|
||||
import { getPlaybackServerId } from './utils/playback/playbackServer';
|
||||
import type { Track } from './store/playerStoreTypes';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { useAuthStore } from './store/authStore';
|
||||
@@ -73,7 +74,8 @@ async function runWorker() {
|
||||
try {
|
||||
while (pendingQueue.length > 0) {
|
||||
const auth = useAuthStore.getState();
|
||||
if (!auth.isLoggedIn || !auth.hotCacheEnabled || !auth.activeServerId) {
|
||||
const playbackSid = getPlaybackServerId();
|
||||
if (!auth.isLoggedIn || !auth.hotCacheEnabled || !playbackSid) {
|
||||
hotCacheFrontendDebug({
|
||||
event: 'prefetch-worker-stop',
|
||||
reason: 'auth-disabled-or-logged-out',
|
||||
@@ -153,7 +155,7 @@ async function runWorker() {
|
||||
continue;
|
||||
}
|
||||
|
||||
const url = buildStreamUrl(job.trackId);
|
||||
const url = buildStreamUrlForServer(job.serverId, job.trackId);
|
||||
try {
|
||||
const customDir = auth.hotCacheDownloadDir || null;
|
||||
hotCacheFrontendDebug({ event: 'prefetch-invoke', trackId: job.trackId });
|
||||
@@ -173,7 +175,7 @@ async function runWorker() {
|
||||
fresh.queue,
|
||||
fresh.queueIndex,
|
||||
maxAfter,
|
||||
authAfter.activeServerId ?? '',
|
||||
getPlaybackServerId(),
|
||||
authAfter.hotCacheDownloadDir || null,
|
||||
);
|
||||
} catch (e: unknown) {
|
||||
@@ -188,7 +190,8 @@ async function runWorker() {
|
||||
|
||||
function scheduleReplan() {
|
||||
const auth = useAuthStore.getState();
|
||||
if (!auth.isLoggedIn || !auth.hotCacheEnabled || !auth.activeServerId) {
|
||||
const playbackSid = getPlaybackServerId();
|
||||
if (!auth.isLoggedIn || !auth.hotCacheEnabled || !playbackSid) {
|
||||
if (debounceTimer) {
|
||||
clearTimeout(debounceTimer);
|
||||
debounceTimer = null;
|
||||
@@ -206,9 +209,10 @@ function scheduleReplan() {
|
||||
|
||||
async function replanNow() {
|
||||
const auth = useAuthStore.getState();
|
||||
if (!auth.isLoggedIn || !auth.hotCacheEnabled || !auth.activeServerId) return;
|
||||
const playbackSid = getPlaybackServerId();
|
||||
if (!auth.isLoggedIn || !auth.hotCacheEnabled || !playbackSid) return;
|
||||
|
||||
const serverId = auth.activeServerId;
|
||||
const serverId = playbackSid;
|
||||
const maxBytes = Math.max(0, auth.hotCacheMaxMb) * 1024 * 1024;
|
||||
const customDir = auth.hotCacheDownloadDir || null;
|
||||
if (maxBytes <= 0) return;
|
||||
@@ -286,8 +290,9 @@ export function initHotCachePrefetch(): () => void {
|
||||
if (onlyIndexMoved && i > prevIdx && prevIdx >= 0 && Array.isArray(prevQ)) {
|
||||
const left = (prevQ as Track[])[prevIdx];
|
||||
const a = useAuthStore.getState();
|
||||
if (left && a.activeServerId) {
|
||||
bumpHotCachePreviousTrackGrace(left.id, a.activeServerId, a.hotCacheDebounceSec);
|
||||
const graceSid = getPlaybackServerId();
|
||||
if (left && graceSid) {
|
||||
bumpHotCachePreviousTrackGrace(left.id, graceSid, a.hotCacheDebounceSec);
|
||||
scheduleEvictAfterPreviousGrace();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user