mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
invalidate recentlyPlayed and mostPlayed carousels on scrobble submission
This commit is contained in:
@@ -133,6 +133,7 @@ const HomeRoute = () => {
|
|||||||
containerQuery={containerQuery}
|
containerQuery={containerQuery}
|
||||||
enableRefresh={carousel.enableRefresh}
|
enableRefresh={carousel.enableRefresh}
|
||||||
key={`carousel-${carousel.uniqueId}`}
|
key={`carousel-${carousel.uniqueId}`}
|
||||||
|
queryKey={['home', carousel.uniqueId] as const}
|
||||||
rowCount={1}
|
rowCount={1}
|
||||||
sortBy={carousel.sortBy as AlbumListSort}
|
sortBy={carousel.sortBy as AlbumListSort}
|
||||||
sortOrder={carousel.sortOrder}
|
sortOrder={carousel.sortOrder}
|
||||||
@@ -147,6 +148,7 @@ const HomeRoute = () => {
|
|||||||
containerQuery={containerQuery}
|
containerQuery={containerQuery}
|
||||||
enableRefresh={carousel.enableRefresh}
|
enableRefresh={carousel.enableRefresh}
|
||||||
key={`carousel-${carousel.uniqueId}`}
|
key={`carousel-${carousel.uniqueId}`}
|
||||||
|
queryKey={['home', carousel.uniqueId] as const}
|
||||||
rowCount={1}
|
rowCount={1}
|
||||||
sortBy={carousel.sortBy as SongListSort}
|
sortBy={carousel.sortBy as SongListSort}
|
||||||
sortOrder={carousel.sortOrder}
|
sortOrder={carousel.sortOrder}
|
||||||
|
|||||||
@@ -20,16 +20,27 @@ export const useSendScrobble = (options?: MutationOptions) => {
|
|||||||
onSuccess: (_data, variables) => {
|
onSuccess: (_data, variables) => {
|
||||||
// Manually increment the play count for the song in the queue if scrobble was submitted
|
// Manually increment the play count for the song in the queue if scrobble was submitted
|
||||||
if (variables.query.submission) {
|
if (variables.query.submission) {
|
||||||
|
const serverId = variables.apiClientProps.serverId;
|
||||||
incrementQueuePlayCount([variables.query.id]);
|
incrementQueuePlayCount([variables.query.id]);
|
||||||
|
|
||||||
// Invalidate the album detail query for the song's album
|
// Invalidate the album detail query for the song's album
|
||||||
if (variables.query.albumId && variables.apiClientProps.serverId) {
|
if (variables.query.albumId) {
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: queryKeys.albums.detail(variables.apiClientProps.serverId, {
|
queryKey: queryKeys.albums.detail(serverId, {
|
||||||
id: variables.query.albumId,
|
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,
|
...options,
|
||||||
|
|||||||
Reference in New Issue
Block a user