mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-10 06:52:43 +01:00
refactor star
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
GetArtistsResponse,
|
||||
GetPlaylistResponse,
|
||||
GetPlaylistsResponse,
|
||||
GetSongResponse,
|
||||
GetTopSongsResponse,
|
||||
Search3Response,
|
||||
SubsonicResponse,
|
||||
@@ -184,6 +185,8 @@ export type LibrarySlice = {
|
||||
fetchLibraryPlaylists: () => Promise<void>
|
||||
fetchLibraryPlaylist: (id: string) => Promise<void>
|
||||
|
||||
fetchLibrarySong: (id: string) => Promise<void>
|
||||
|
||||
fetchLibraryAlbumList: (params: GetAlbumList2Params) => Promise<string[]>
|
||||
fetchLibrarySearchResults: (params: Search3Params) => Promise<SearchResults>
|
||||
star: (params: StarParams) => Promise<void>
|
||||
@@ -405,6 +408,28 @@ export const createLibrarySlice = (set: SetState<Store>, get: GetState<Store>):
|
||||
)
|
||||
},
|
||||
|
||||
fetchLibrarySong: async id => {
|
||||
const client = get().client
|
||||
if (!client) {
|
||||
return
|
||||
}
|
||||
|
||||
let response: SubsonicResponse<GetSongResponse>
|
||||
try {
|
||||
response = await client.getSong({ id })
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
const song = mapSong(response.data.song)
|
||||
|
||||
set(
|
||||
produce<LibrarySlice>(state => {
|
||||
state.entities.songs[id] = song
|
||||
}),
|
||||
)
|
||||
},
|
||||
|
||||
fetchLibraryAlbumList: async params => {
|
||||
const client = get().client
|
||||
if (!client) {
|
||||
|
||||
Reference in New Issue
Block a user