From f998491beb510aaeb4182f85219d72701d109ccd Mon Sep 17 00:00:00 2001 From: Kendall Garner <17521368+kgarner7@users.noreply.github.com> Date: Mon, 2 Feb 2026 20:48:44 -0800 Subject: [PATCH] fix(playlist): optimistically update rating for playlist song list --- .../mutations/rating-optimistic-updates.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/renderer/features/shared/mutations/rating-optimistic-updates.ts b/src/renderer/features/shared/mutations/rating-optimistic-updates.ts index 0a536c052..83b92ccf9 100644 --- a/src/renderer/features/shared/mutations/rating-optimistic-updates.ts +++ b/src/renderer/features/shared/mutations/rating-optimistic-updates.ts @@ -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(item), + ); + return updatedItems ? { ...prev, items: updatedItems } : prev; + }, + }); + } + }); + const topSongsQueryKey = queryKeys.albumArtists.topSongs( variables.apiClientProps.serverId, );