From f9592f2d82191a873c93aab90359ad64f06a202f Mon Sep 17 00:00:00 2001 From: Eclypsed Date: Mon, 15 Apr 2024 22:26:38 -0400 Subject: [PATCH] Changed currentlyPlaying to queue --- src/lib/components/media/mediaCard.svelte | 15 +++++++------- src/lib/components/media/mediaPlayer.svelte | 23 ++++++++++++--------- src/lib/stores.ts | 2 +- src/routes/(app)/search/+page.svelte | 16 ++++++++++++-- 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/lib/components/media/mediaCard.svelte b/src/lib/components/media/mediaCard.svelte index 7c7b0bd..af76632 100644 --- a/src/lib/components/media/mediaCard.svelte +++ b/src/lib/components/media/mediaCard.svelte @@ -3,15 +3,9 @@ import IconButton from '$lib/components/util/iconButton.svelte' import { goto } from '$app/navigation' - import { currentlyPlaying } from '$lib/stores' + import { queue } from '$lib/stores' let image: HTMLImageElement, captionText: HTMLDivElement - - const setCurrentlyPlaying = () => { - if (mediaItem.type === 'song') { - $currentlyPlaying = mediaItem - } - }
@@ -31,7 +25,12 @@
{/if} - + { + if (mediaItem.type === 'song') $queue.push(mediaItem) + }} + > diff --git a/src/lib/components/media/mediaPlayer.svelte b/src/lib/components/media/mediaPlayer.svelte index 8a3c2a3..658d12e 100644 --- a/src/lib/components/media/mediaPlayer.svelte +++ b/src/lib/components/media/mediaPlayer.svelte @@ -1,10 +1,13 @@ -{#if $currentlyPlaying} +{#if currentlyPlaying}
- {#key $currentlyPlaying} -
+ {#key currentlyPlaying} +
{/key}
-
{$currentlyPlaying.name}
-
{$currentlyPlaying.artists?.map((artist) => artist.name).join(', ') || $currentlyPlaying.createdBy?.name}
+
{currentlyPlaying.name}
+
{currentlyPlaying.artists?.map((artist) => artist.name).join(', ') || currentlyPlaying.createdBy?.name}
@@ -78,7 +81,7 @@
- +
- +
@@ -105,11 +108,11 @@ -
-
{/if} diff --git a/src/lib/stores.ts b/src/lib/stores.ts index e8c32c4..7961b87 100644 --- a/src/lib/stores.ts +++ b/src/lib/stores.ts @@ -5,7 +5,7 @@ export const pageWidth: Writable = writable() export const newestAlert: Writable<[AlertType, string]> = writable() -export const currentlyPlaying: Writable = writable() +export const queue: Writable = writable() const youtubeMusicBackground: string = 'https://www.gstatic.com/youtube/media/ytm/images/sbg/wsbg@4000x2250.png' // Default Youtube music background export const backgroundImage: Writable = writable(youtubeMusicBackground) diff --git a/src/routes/(app)/search/+page.svelte b/src/routes/(app)/search/+page.svelte index e0da77f..7e2a4f8 100644 --- a/src/routes/(app)/search/+page.svelte +++ b/src/routes/(app)/search/+page.svelte @@ -1,8 +1,17 @@ {#if data.searchResults} @@ -13,7 +22,7 @@