mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 04:20:12 +02:00
fix(playlist): optimistically update rating for playlist song list
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
AlbumListResponse,
|
||||
ArtistListResponse,
|
||||
LibraryItem,
|
||||
PlaylistSongListResponse,
|
||||
SetRatingArgs,
|
||||
Song,
|
||||
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(
|
||||
variables.apiClientProps.serverId,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user