mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 14:35:41 +00:00
fix(playback): Lucky Mix after switching Subsonic servers (#785)
* fix(playback): Lucky Mix after switching Subsonic servers Hand off unpinned legacy queues to the browsed server, start the mix lock before async work, skip cross-server enqueue toasts while rolling, bind queue server before batch enqueues, and restore queueServerId on failed builds. * chore(release): CHANGELOG and credits for PR #785
This commit is contained in:
@@ -34,12 +34,25 @@ export function playbackServerDiffersFromActive(): boolean {
|
||||
return !!activeSid && queueServerId !== activeSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* True when the current queue belongs to another server (or is unpinned legacy
|
||||
* state) and a browsed-server mix should clear it before enqueueing new tracks.
|
||||
*/
|
||||
export function shouldHandoffQueueToActiveServer(): boolean {
|
||||
const activeSid = useAuthStore.getState().activeServerId;
|
||||
if (!activeSid) return false;
|
||||
const { queue, queueServerId } = usePlayerStore.getState();
|
||||
if ((queue?.length ?? 0) === 0) return false;
|
||||
if (!queueServerId) return true;
|
||||
return queueServerId !== activeSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop playback owned by another server so a new mix on the browsed server
|
||||
* can replace the queue (Lucky Mix / similar flows after ConnectionIndicator switch).
|
||||
*/
|
||||
export function prepareActiveServerForNewMix(): void {
|
||||
if (!playbackServerDiffersFromActive()) return;
|
||||
if (!shouldHandoffQueueToActiveServer()) return;
|
||||
usePlayerStore.getState().clearQueue();
|
||||
bindQueueServerForPlayback();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user