mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-13 07:42:31 +02:00
enable refresh for all home carousels, and fix favorite/rating on home
This commit is contained in:
@@ -46,6 +46,7 @@ const HomeRoute = () => {
|
|||||||
|
|
||||||
const carousels = {
|
const carousels = {
|
||||||
[HomeItem.MOST_PLAYED]: {
|
[HomeItem.MOST_PLAYED]: {
|
||||||
|
enableRefresh: true,
|
||||||
itemType: isJellyfin ? LibraryItem.SONG : LibraryItem.ALBUM,
|
itemType: isJellyfin ? LibraryItem.SONG : LibraryItem.ALBUM,
|
||||||
sortBy: isJellyfin ? SongListSort.PLAY_COUNT : AlbumListSort.PLAY_COUNT,
|
sortBy: isJellyfin ? SongListSort.PLAY_COUNT : AlbumListSort.PLAY_COUNT,
|
||||||
sortOrder: SortOrder.DESC,
|
sortOrder: SortOrder.DESC,
|
||||||
@@ -59,18 +60,21 @@ const HomeRoute = () => {
|
|||||||
title: t('page.home.explore', { postProcess: 'sentenceCase' }),
|
title: t('page.home.explore', { postProcess: 'sentenceCase' }),
|
||||||
},
|
},
|
||||||
[HomeItem.RECENTLY_ADDED]: {
|
[HomeItem.RECENTLY_ADDED]: {
|
||||||
|
enableRefresh: true,
|
||||||
itemType: LibraryItem.ALBUM,
|
itemType: LibraryItem.ALBUM,
|
||||||
sortBy: AlbumListSort.RECENTLY_ADDED,
|
sortBy: AlbumListSort.RECENTLY_ADDED,
|
||||||
sortOrder: SortOrder.DESC,
|
sortOrder: SortOrder.DESC,
|
||||||
title: t('page.home.newlyAdded', { postProcess: 'sentenceCase' }),
|
title: t('page.home.newlyAdded', { postProcess: 'sentenceCase' }),
|
||||||
},
|
},
|
||||||
[HomeItem.RECENTLY_PLAYED]: {
|
[HomeItem.RECENTLY_PLAYED]: {
|
||||||
|
enableRefresh: true,
|
||||||
itemType: isJellyfin ? LibraryItem.SONG : LibraryItem.ALBUM,
|
itemType: isJellyfin ? LibraryItem.SONG : LibraryItem.ALBUM,
|
||||||
sortBy: isJellyfin ? SongListSort.RECENTLY_PLAYED : AlbumListSort.RECENTLY_PLAYED,
|
sortBy: isJellyfin ? SongListSort.RECENTLY_PLAYED : AlbumListSort.RECENTLY_PLAYED,
|
||||||
sortOrder: SortOrder.DESC,
|
sortOrder: SortOrder.DESC,
|
||||||
title: t('page.home.recentlyPlayed', { postProcess: 'sentenceCase' }),
|
title: t('page.home.recentlyPlayed', { postProcess: 'sentenceCase' }),
|
||||||
},
|
},
|
||||||
[HomeItem.RECENTLY_RELEASED]: {
|
[HomeItem.RECENTLY_RELEASED]: {
|
||||||
|
enableRefresh: true,
|
||||||
itemType: LibraryItem.ALBUM,
|
itemType: LibraryItem.ALBUM,
|
||||||
sortBy: AlbumListSort.RELEASE_DATE,
|
sortBy: AlbumListSort.RELEASE_DATE,
|
||||||
sortOrder: SortOrder.DESC,
|
sortOrder: SortOrder.DESC,
|
||||||
@@ -142,7 +146,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}
|
queryKey={['home', 'album', carousel.uniqueId] as const}
|
||||||
rowCount={1}
|
rowCount={1}
|
||||||
sortBy={carousel.sortBy as AlbumListSort}
|
sortBy={carousel.sortBy as AlbumListSort}
|
||||||
sortOrder={carousel.sortOrder}
|
sortOrder={carousel.sortOrder}
|
||||||
@@ -157,7 +161,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}
|
queryKey={['home', 'song', carousel.uniqueId] as const}
|
||||||
rowCount={1}
|
rowCount={1}
|
||||||
sortBy={carousel.sortBy as SongListSort}
|
sortBy={carousel.sortBy as SongListSort}
|
||||||
sortOrder={carousel.sortOrder}
|
sortOrder={carousel.sortOrder}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
PlaylistSongListResponse,
|
PlaylistSongListResponse,
|
||||||
Song,
|
Song,
|
||||||
SongDetailResponse,
|
SongDetailResponse,
|
||||||
|
SongListResponse,
|
||||||
TopSongListResponse,
|
TopSongListResponse,
|
||||||
} from '/@/shared/types/domain-types';
|
} from '/@/shared/types/domain-types';
|
||||||
|
|
||||||
@@ -155,7 +156,12 @@ export const applyFavoriteOptimisticUpdates = (
|
|||||||
queryKey: infiniteListQueryKey,
|
queryKey: infiniteListQueryKey,
|
||||||
});
|
});
|
||||||
|
|
||||||
infiniteListQueries.forEach(([queryKey, data]) => {
|
const homeQueries = queryClient.getQueriesData({
|
||||||
|
exact: false,
|
||||||
|
queryKey: ['home', 'album'],
|
||||||
|
});
|
||||||
|
|
||||||
|
infiniteListQueries.concat(homeQueries).forEach(([queryKey, data]) => {
|
||||||
if (data) {
|
if (data) {
|
||||||
pendingUpdates.push({
|
pendingUpdates.push({
|
||||||
previousData: data,
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,12 @@ export const applyRatingOptimisticUpdates = (
|
|||||||
queryKey: infiniteListQueryKey,
|
queryKey: infiniteListQueryKey,
|
||||||
});
|
});
|
||||||
|
|
||||||
infiniteListQueries.forEach(([queryKey, data]) => {
|
const homeQueries = queryClient.getQueriesData({
|
||||||
|
exact: false,
|
||||||
|
queryKey: ['home', 'album'],
|
||||||
|
});
|
||||||
|
|
||||||
|
infiniteListQueries.concat(homeQueries).forEach(([queryKey, data]) => {
|
||||||
if (data) {
|
if (data) {
|
||||||
pendingUpdates.push({
|
pendingUpdates.push({
|
||||||
previousData: data,
|
previousData: data,
|
||||||
|
|||||||
Reference in New Issue
Block a user