diff --git a/app/models/music.ts b/app/models/music.ts index 124824a..fdcbb45 100644 --- a/app/models/music.ts +++ b/app/models/music.ts @@ -6,13 +6,6 @@ export interface Artist { coverArt?: string } -export interface ArtistInfo extends Artist { - albums: Album[] - smallImageUrl?: string - largeImageUrl?: string - topSongs: Song[] -} - export interface AlbumListItem { itemType: 'album' id: string diff --git a/app/state/music.ts b/app/state/music.ts index b221f11..07c9bc2 100644 --- a/app/state/music.ts +++ b/app/state/music.ts @@ -2,7 +2,6 @@ import { AlbumListItem, AlbumWithSongs, Artist, - ArtistInfo, HomeLists, PlaylistListItem, PlaylistWithSongs, @@ -18,9 +17,6 @@ export type MusicSlice = { // // family-style state // - artistInfo: { [id: string]: ArtistInfo } - fetchArtistInfo: (id: string) => Promise - albumsWithSongs: { [id: string]: AlbumWithSongs } fetchAlbumWithSongs: (id: string) => Promise @@ -60,7 +56,6 @@ export type MusicSlice = { } export const selectMusic = { - fetchArtistInfo: (state: Store) => state.fetchArtistInfo, fetchAlbumWithSongs: (state: Store) => state.fetchAlbumWithSongs, fetchPlaylistWithSongs: (state: Store) => state.fetchPlaylistWithSongs, @@ -91,41 +86,6 @@ function reduceStarred( } export const createMusicSlice = (set: SetState, get: GetState): MusicSlice => ({ - artistInfo: {}, - - fetchArtistInfo: async id => { - const client = get().client - if (!client) { - return undefined - } - - try { - const [artistResponse, artistInfoResponse] = await Promise.all([ - client.getArtist({ id }), - client.getArtistInfo2({ id }), - ]) - const topSongsResponse = await client.getTopSongs({ artist: artistResponse.data.artist.name, count: 50 }) - const artistInfo = await get().mapArtistInfo( - artistResponse.data, - artistInfoResponse.data.artistInfo, - topSongsResponse.data.songs, - ) - - set( - produce(state => { - state.artistInfo[id] = artistInfo - - state.starredSongs = reduceStarred(state.starredSongs, artistInfo.topSongs) - state.starredArtists = reduceStarred(state.starredArtists, [artistInfo]) - state.starredAlbums = reduceStarred(state.starredAlbums, artistInfo.albums) - }), - ) - return artistInfo - } catch { - return undefined - } - }, - albumsWithSongs: {}, fetchAlbumWithSongs: async id => { diff --git a/app/state/musicmap.ts b/app/state/musicmap.ts index a8b4601..df43def 100644 --- a/app/state/musicmap.ts +++ b/app/state/musicmap.ts @@ -1,21 +1,11 @@ -import { - AlbumListItem, - AlbumWithSongs, - Artist, - ArtistInfo, - PlaylistListItem, - PlaylistWithSongs, - Song, -} from '@app/models/music' +import { AlbumListItem, AlbumWithSongs, Artist, PlaylistListItem, PlaylistWithSongs, Song } from '@app/models/music' import { AlbumID3Element, ArtistID3Element, - ArtistInfo2Element, ChildElement, PlaylistElement, PlaylistWithSongsElement, } from '@app/subsonic/elements' -import { GetArtistResponse } from '@app/subsonic/responses' import { GetState, SetState } from 'zustand' import { Store } from './store' @@ -23,11 +13,6 @@ export type MusicMapSlice = { mapChildToSong: (child: ChildElement, coverArt?: string) => Promise mapChildrenToSongs: (children: ChildElement[], coverArt?: string) => Promise mapArtistID3toArtist: (artist: ArtistID3Element) => Artist - mapArtistInfo: ( - artistResponse: GetArtistResponse, - info: ArtistInfo2Element, - topSongs: ChildElement[], - ) => Promise mapAlbumID3toAlbumListItem: (album: AlbumID3Element) => AlbumListItem mapAlbumID3toAlbum: (album: AlbumID3Element) => AlbumListItem mapAlbumID3WithSongstoAlbumWithSongs: (album: AlbumID3Element, songs: ChildElement[]) => Promise @@ -81,20 +66,6 @@ export const createMusicMapSlice = (set: SetState, get: GetState): } }, - mapArtistInfo: async (artistResponse, info, topSongs) => { - const { artist, albums } = artistResponse - - const mappedAlbums = albums.map(get().mapAlbumID3toAlbum) - - return { - ...get().mapArtistID3toArtist(artist), - albums: mappedAlbums, - smallImageUrl: info.smallImageUrl, - largeImageUrl: info.largeImageUrl, - topSongs: (await get().mapChildrenToSongs(topSongs)).slice(0, 5), - } - }, - mapAlbumID3toAlbumListItem: album => { return { itemType: 'album',