fix: Sync queue state before reading in radio creation
Call syncQueueState() to fetch queue from backend before attempting playback
This commit is contained in:
1 parent
b2c413b3fd
commit
6c3ff71cdd
1 file changed
+8
-1
@@ -6,7 +6,7 @@
|
|||||||
import TrackMenu from '../TrackMenu.svelte';
|
import TrackMenu from '../TrackMenu.svelte';
|
||||||
import { consumeContextTrackFocus, setPlaybackContext } from '$lib/stores/playbackContextStore';
|
import { consumeContextTrackFocus, setPlaybackContext } from '$lib/stores/playbackContextStore';
|
||||||
import { togglePlay } from '$lib/stores/playerStore';
|
import { togglePlay } from '$lib/stores/playerStore';
|
||||||
import { getQueue } from '$lib/stores/queueStore';
|
import { getQueue, syncQueueState } from '$lib/stores/queueStore';
|
||||||
import { tick } from 'svelte';
|
import { tick } from 'svelte';
|
||||||
|
|
||||||
interface Track {
|
interface Track {
|
||||||
@@ -260,11 +260,16 @@
|
|||||||
});
|
});
|
||||||
console.log(`[Radio] Artist radio created: ${sessionId}`);
|
console.log(`[Radio] Artist radio created: ${sessionId}`);
|
||||||
|
|
||||||
|
// Sync queue state from backend
|
||||||
|
await syncQueueState();
|
||||||
|
|
||||||
// Get the first track from queue and start playback
|
// Get the first track from queue and start playback
|
||||||
const queue = getQueue();
|
const queue = getQueue();
|
||||||
|
console.log(`[Radio] Queue length: ${queue.length}, onTrackPlay defined: ${!!onTrackPlay}`);
|
||||||
|
|
||||||
if (queue.length > 0 && onTrackPlay) {
|
if (queue.length > 0 && onTrackPlay) {
|
||||||
const firstTrack = queue[0];
|
const firstTrack = queue[0];
|
||||||
|
console.log(`[Radio] First track:`, firstTrack);
|
||||||
// Start playback using the onTrackPlay callback
|
// Start playback using the onTrackPlay callback
|
||||||
onTrackPlay({
|
onTrackPlay({
|
||||||
id: Number(firstTrack.id),
|
id: Number(firstTrack.id),
|
||||||
@@ -279,6 +284,8 @@
|
|||||||
samplingRate: firstTrack.sample_rate ?? undefined,
|
samplingRate: firstTrack.sample_rate ?? undefined,
|
||||||
});
|
});
|
||||||
console.log(`[Radio] Started playback of track ${firstTrack.id}`);
|
console.log(`[Radio] Started playback of track ${firstTrack.id}`);
|
||||||
|
} else {
|
||||||
|
console.log(`[Radio] Cannot start playback - queue: ${queue.length}, onTrackPlay: ${!!onTrackPlay}`);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to create artist radio:', err);
|
console.error('Failed to create artist radio:', err);
|
||||||
|
|||||||
Reference in new issue
Block a user