invalidate recentlyPlayed and mostPlayed carousels on scrobble submission

This commit is contained in:
jeffvli
2026-01-16 04:35:06 -08:00
parent a59e57572c
commit dc5414284a
2 changed files with 15 additions and 2 deletions
@@ -20,16 +20,27 @@ export const useSendScrobble = (options?: MutationOptions) => {
onSuccess: (_data, variables) => {
// Manually increment the play count for the song in the queue if scrobble was submitted
if (variables.query.submission) {
const serverId = variables.apiClientProps.serverId;
incrementQueuePlayCount([variables.query.id]);
// Invalidate the album detail query for the song's album
if (variables.query.albumId && variables.apiClientProps.serverId) {
if (variables.query.albumId) {
queryClient.invalidateQueries({
queryKey: queryKeys.albums.detail(variables.apiClientProps.serverId, {
queryKey: queryKeys.albums.detail(serverId, {
id: variables.query.albumId,
}),
});
}
// Invalidate recently played carousel on home route
queryClient.invalidateQueries({
queryKey: ['home', 'recentlyPlayed'],
});
// Invalidate most played carousel on home route
queryClient.invalidateQueries({
queryKey: ['home', 'mostPlayed'],
});
}
},
...options,