From a4bad9d73b30eaa20c5b31e2cd7d154cdcc1721c Mon Sep 17 00:00:00 2001 From: Eclypsed Date: Wed, 27 Mar 2024 23:53:59 -0400 Subject: [PATCH] Removed MediaItem type --- src/app.d.ts | 32 +++++++++++-------- src/lib/components/media/mediaCard.svelte | 8 ++--- .../media/scrollableCardMenu.svelte | 2 +- src/lib/server/db.ts | 6 ++-- src/lib/server/jellyfin.ts | 6 ++-- src/lib/server/youtube-music.ts | 12 +++---- .../users/[userId]/recommendations/+server.ts | 2 +- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/app.d.ts b/src/app.d.ts index 11bbd18..b5faf16 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -24,8 +24,6 @@ declare global { passwordHash: string } - type serviceType = 'jellyfin' | 'youtube-music' - type ConnectionInfo = { id: string userId: string @@ -43,27 +41,24 @@ declare global { ) interface Connection { - getRecommendations: () => Promise + getRecommendations: () => Promise<(Song | Album | Playlist)[]> getConnectionInfo: () => Promise - search: (searchTerm: string) => Promise + search: (searchTerm: string) => Promise<(Song | Album | Playlist)[]> } // These Schemas should only contain general info data that is necessary for data fetching purposes. // They are NOT meant to be stores for large amounts of data, i.e. Don't include the data for every single song the Playlist type. // Big data should be fetched as needed in the app, these exist to ensure that the info necessary to fetch that data is there. - interface MediaItem { - type: 'song' | 'album' | 'playlist' | 'artist' - id: string - name: string - thumbnail?: string - } - interface Song extends MediaItem { + type Song = { connection: { id: string type: serviceType } + id: string + name: string type: 'song' duration?: number + thumbnail?: string artists?: { id: string name: string @@ -77,13 +72,16 @@ declare global { releaseDate?: string } - interface Album extends MediaItem { + type Album = { connection: { id: string type: serviceType } + id: string + name: string type: 'album' duration?: number + thumbnail?: string artists?: { // Album Artists id: string @@ -93,8 +91,11 @@ declare global { } // IMPORTANT: This interface is for Lazuli created and stored playlists. Use service-specific interfaces when pulling playlists from services - interface Playlist extends MediaItem { + type Playlist = { + id: string + name: string type: 'playlist' + thumbnail?: string description?: string items: { connectionId: string @@ -102,8 +103,11 @@ declare global { }[] } - interface Artist extends MediaItem { + type Artist = { + id: string + name: string type: 'artist' + thumbnail?: string } namespace Jellyfin { diff --git a/src/lib/components/media/mediaCard.svelte b/src/lib/components/media/mediaCard.svelte index d789155..a3006c0 100644 --- a/src/lib/components/media/mediaCard.svelte +++ b/src/lib/components/media/mediaCard.svelte @@ -1,14 +1,10 @@
@@ -29,7 +25,7 @@
{mediaItem.name}
- {#if checkSongOrAlbum(mediaItem) && 'artists' in mediaItem && mediaItem.artists} + {#if 'artists' in mediaItem && mediaItem.artists} {#each mediaItem.artists as artist} {@const listIndex = mediaItem.artists.indexOf(artist)} {artist.name} diff --git a/src/lib/components/media/scrollableCardMenu.svelte b/src/lib/components/media/scrollableCardMenu.svelte index a46c176..fd258b0 100644 --- a/src/lib/components/media/scrollableCardMenu.svelte +++ b/src/lib/components/media/scrollableCardMenu.svelte @@ -1,6 +1,6 @@