diff --git a/src/lib/components/groove/PlaylistListing.svelte b/src/lib/components/groove/PlaylistListing.svelte index 9d4da20..940084c 100644 --- a/src/lib/components/groove/PlaylistListing.svelte +++ b/src/lib/components/groove/PlaylistListing.svelte @@ -8,6 +8,7 @@ import type { SubmitFunction } from '../../../routes/playlists/[id]/$types'; import { getCoverUrl } from '$lib/covers'; import { getLibraryState } from '$lib/library.svelte'; + import { getPlayerState } from '$lib/player.svelte'; interface Props { id: number; @@ -21,6 +22,7 @@ ); const library = getLibraryState(); + const player = getPlayerState(); let coverImages = $derived.by(() => { if (tracks.length === 0) { @@ -53,11 +55,15 @@ }); const playPlaylist: SubmitFunction = async () => { - return async ({ update }) => { + return async ({ update, result }) => { await update({ invalidateAll: false, reset: false }); + + if (result.type === 'success' && result.data) { + player.applyStatus(result.data); + } }; }; diff --git a/src/routes/playlists/[id]/+page.server.ts b/src/routes/playlists/[id]/+page.server.ts index 73cb582..589600c 100644 --- a/src/routes/playlists/[id]/+page.server.ts +++ b/src/routes/playlists/[id]/+page.server.ts @@ -2,14 +2,18 @@ import type { Actions } from './$types'; import { protoTransport } from '../../../hooks.server'; import { PlayerClient } from '$lib/proto/player.client'; import { LibraryClient } from '$lib/proto/library.client'; +import { serializable } from '$lib/proto'; +import type { PlayerStatus } from '$lib/proto/player'; export const actions = { play: async ({ params }) => { const client = new PlayerClient(protoTransport); - const _response = await client.playPlaylist({ + const response = await client.playPlaylist({ id: parseInt(params.id) }); + + return serializable(response.response); }, delete: async ({ params }) => { const client = new LibraryClient(protoTransport);