mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-08 13:00:13 +02:00
enable refresh for all home carousels, and fix favorite/rating on home
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
PlaylistSongListResponse,
|
||||
Song,
|
||||
SongDetailResponse,
|
||||
SongListResponse,
|
||||
TopSongListResponse,
|
||||
} from '/@/shared/types/domain-types';
|
||||
|
||||
@@ -155,7 +156,12 @@ export const applyFavoriteOptimisticUpdates = (
|
||||
queryKey: infiniteListQueryKey,
|
||||
});
|
||||
|
||||
infiniteListQueries.forEach(([queryKey, data]) => {
|
||||
const homeQueries = queryClient.getQueriesData({
|
||||
exact: false,
|
||||
queryKey: ['home', 'album'],
|
||||
});
|
||||
|
||||
infiniteListQueries.concat(homeQueries).forEach(([queryKey, data]) => {
|
||||
if (data) {
|
||||
pendingUpdates.push({
|
||||
previousData: data,
|
||||
@@ -538,6 +544,33 @@ export const applyFavoriteOptimisticUpdates = (
|
||||
}
|
||||
});
|
||||
|
||||
const homeQueries = queryClient.getQueriesData({
|
||||
exact: false,
|
||||
queryKey: ['home', 'song'],
|
||||
});
|
||||
|
||||
homeQueries.concat(homeQueries).forEach(([queryKey, data]) => {
|
||||
if (data) {
|
||||
pendingUpdates.push({
|
||||
previousData: data,
|
||||
queryKey,
|
||||
updater: (
|
||||
current:
|
||||
| undefined
|
||||
| { pageParams: string[]; pages: SongListResponse[] },
|
||||
) => {
|
||||
if (!current) return current;
|
||||
const updatedPages = updateItemsInPages<Song, SongListResponse>(
|
||||
current.pages.filter((p): p is SongListResponse => !!p),
|
||||
itemIdSet,
|
||||
(item) => createFavoriteUpdater<Song>(item),
|
||||
);
|
||||
return updatedPages ? { ...current, pages: updatedPages } : current;
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,12 @@ export const applyRatingOptimisticUpdates = (
|
||||
queryKey: infiniteListQueryKey,
|
||||
});
|
||||
|
||||
infiniteListQueries.forEach(([queryKey, data]) => {
|
||||
const homeQueries = queryClient.getQueriesData({
|
||||
exact: false,
|
||||
queryKey: ['home', 'album'],
|
||||
});
|
||||
|
||||
infiniteListQueries.concat(homeQueries).forEach(([queryKey, data]) => {
|
||||
if (data) {
|
||||
pendingUpdates.push({
|
||||
previousData: data,
|
||||
|
||||
Reference in New Issue
Block a user