fix: SITE_URL
This commit is contained in:
1 parent
1fe912f4bd
commit
dfdfb79169
66 files changed
+1352
-240
No files matched your search
+28
-10
@@ -1,28 +1,46 @@
|
||||
'use client';
|
||||
|
||||
import usersShowsQuery from '@/data/queries/usersShows';
|
||||
import useMounted from '@/hooks/useMounted';
|
||||
|
||||
import useInfiniteList from './useInfiniteList';
|
||||
import { useFavorites, useWatchList } from './useLocalUsersLists';
|
||||
import { useSession } from './useSession';
|
||||
import usersShowsQuery from '@/api/queries/usersShows';
|
||||
|
||||
const useUsersShows = ({ showType, list = 'favorite' }: { showType: Show['type']; list: 'favorite' | 'watchlist' }) => {
|
||||
const session = useSession();
|
||||
const useUsersShows = ({
|
||||
showType,
|
||||
list = 'favorite',
|
||||
session: serverSession
|
||||
}: {
|
||||
showType: Show['type'];
|
||||
list: 'favorite' | 'watchlist';
|
||||
session?: string;
|
||||
}) => {
|
||||
const isMounted = useMounted();
|
||||
const clientSession = useSession();
|
||||
|
||||
const session = isMounted ? clientSession : serverSession;
|
||||
|
||||
const { shows: favorite } = useFavorites();
|
||||
const { shows: watchlist } = useWatchList();
|
||||
|
||||
const query = useInfiniteList(usersShowsQuery({ showType, list, session }));
|
||||
const query = useInfiniteList({
|
||||
...usersShowsQuery({ showType, list, session }),
|
||||
enabled: Boolean(session)
|
||||
});
|
||||
|
||||
return session
|
||||
? query
|
||||
: {
|
||||
fetchNextPage: undefined,
|
||||
isLoading: false,
|
||||
isFetched: true,
|
||||
shows: {
|
||||
favorite: favorite.filter((show) => show.type === showType),
|
||||
watchlist: watchlist.filter((show) => show.type === showType)
|
||||
}[list]
|
||||
isLoading: isMounted,
|
||||
isFetched: isMounted,
|
||||
shows: isMounted
|
||||
? {
|
||||
favorite: favorite.filter((show) => show.type === showType),
|
||||
watchlist: watchlist.filter((show) => show.type === showType)
|
||||
}[list]
|
||||
: []
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user