fix(playlists): update player state after pressing play
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -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<PlayerStatus>(response.response);
|
||||
},
|
||||
delete: async ({ params }) => {
|
||||
const client = new LibraryClient(protoTransport);
|
||||
|
||||
Reference in New Issue
Block a user