Improve cache key when no query, reduce stale time

This commit is contained in:
Jackson Harper
2024-08-15 12:20:24 +08:00
parent 5373f16328
commit 9e86ddc39b

View File

@ -220,7 +220,8 @@ export function useGetLibraryItems(
console.log('fullQuery: ', fullQuery)
return useInfiniteQuery({
queryKey: ['libraryItems', folder, fullQuery],
// If no folder is specified cache this as `home`
queryKey: ['libraryItems', folder ?? 'home', fullQuery],
queryFn: async ({ pageParam }) => {
const response = (await gqlFetcher(gqlSearchQuery(includeCount), {
after: pageParam,
@ -232,7 +233,7 @@ export function useGetLibraryItems(
},
enabled,
initialPageParam: '0',
staleTime: 5 * 60 * 1000,
staleTime: 60 * 1000,
getNextPageParam: (lastPage: LibraryItems) => {
console.log(
'lastPage.pageInfo.hasNextPage: ',