fix: back to prefetch

This commit is contained in:
ner committed 2024-10-29 18:25:52 +02:00
1 parent a268f7c38d
commit c9ca262da8
14 files changed
+180 -27

No files matched your search

+20 -2
View File
@@ -1,14 +1,32 @@
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
import { Metadata } from 'next';
import UsersList from '@/components/UsersLists';
import { session } from '@/data';
import { session as getSession, session } from '@/data';
import usersShowsQuery from '@/data/queries/usersShows';
import { TITLE } from '@/env';
import getQueryClient from '@/lib/queryClient';
export const metadata: Metadata = {
title: `My watch list - ${TITLE}`,
description: `View your favorite shows on ${TITLE}. Keep track of films you’ve added and revisit your top picks anytime.`
};
const WatchList = async () => <UsersList session={await session()} list='watchlist' label='watch' />;
const WatchList = async () => {
const session = await getSession();
const queryClient = getQueryClient();
const list = 'watchlist';
if (session) {
queryClient.prefetchInfiniteQuery(usersShowsQuery({ showType: 'movie', session, list }));
}
return (
<HydrationBoundary state={dehydrate(queryClient)}>
<UsersList session={session} list={list} label='watch' />
</HydrationBoundary>
);
};
export default WatchList;