mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
fix(playlist): optimistically update rating for playlist song list
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
|||||||
AlbumListResponse,
|
AlbumListResponse,
|
||||||
ArtistListResponse,
|
ArtistListResponse,
|
||||||
LibraryItem,
|
LibraryItem,
|
||||||
|
PlaylistSongListResponse,
|
||||||
SetRatingArgs,
|
SetRatingArgs,
|
||||||
Song,
|
Song,
|
||||||
SongDetailResponse,
|
SongDetailResponse,
|
||||||
@@ -494,6 +495,30 @@ export const applyRatingOptimisticUpdates = (
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const playlistSongListQueryKey = queryKeys.playlists.songList(
|
||||||
|
variables.apiClientProps.serverId,
|
||||||
|
);
|
||||||
|
const playlistSongListQueries = queryClient.getQueriesData({
|
||||||
|
exact: false,
|
||||||
|
queryKey: playlistSongListQueryKey,
|
||||||
|
});
|
||||||
|
|
||||||
|
playlistSongListQueries.forEach(([queryKey, data]) => {
|
||||||
|
if (data) {
|
||||||
|
pendingUpdates.push({
|
||||||
|
previousData: data,
|
||||||
|
queryKey,
|
||||||
|
updater: (prev: PlaylistSongListResponse | undefined) => {
|
||||||
|
if (!prev) return prev;
|
||||||
|
const updatedItems = updateItemInArray(prev.items, itemIdSet, (item) =>
|
||||||
|
createRatingUpdater<Song>(item),
|
||||||
|
);
|
||||||
|
return updatedItems ? { ...prev, items: updatedItems } : prev;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const topSongsQueryKey = queryKeys.albumArtists.topSongs(
|
const topSongsQueryKey = queryKeys.albumArtists.topSongs(
|
||||||
variables.apiClientProps.serverId,
|
variables.apiClientProps.serverId,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user