fix: SITE_URL
This commit is contained in:
1 parent
1fe912f4bd
commit
dfdfb79169
66 files changed
+1352
-240
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
|
||||
import accountQuery from '@/data/queries/account';
|
||||
import { useSession } from '@/hooks/useSession';
|
||||
import accountQuery from '@/api/queries/account';
|
||||
|
||||
const useAccount = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ import { useCallback } from 'react';
|
||||
import { atom, useAtomValue, useSetAtom } from 'jotai';
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
const sessionAtom = atom<string | null>(Cookies.get('session') as string);
|
||||
const sessionAtom = atom<string | undefined>(Cookies.get('session') as string);
|
||||
|
||||
export const useSession = () => useAtomValue(sessionAtom);
|
||||
|
||||
@@ -10,7 +10,7 @@ export const useSetSession = () => {
|
||||
const setSession = useSetAtom(sessionAtom);
|
||||
|
||||
return useCallback(
|
||||
(session: string | null) => {
|
||||
(session: string | undefined) => {
|
||||
typeof session === 'string' ? Cookies.set('session', session) : Cookies.remove('session');
|
||||
setSession(session);
|
||||
},
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
|
||||
import { accountStates, updateAccountStates } from '@/api';
|
||||
import { KEY as USERS_SHOWS_KEY } from '@/data/queries/usersShows';
|
||||
|
||||
import { accountStates, updateAccountStates } from '../data';
|
||||
|
||||
import { useFavorites, useFavoritesStateToggle, useWatchList, useWatchListStateToggle } from './useLocalUsersLists';
|
||||
import { useSession } from './useSession';
|
||||
import { KEY as USERS_SHOWS_KEY } from '@/api/queries/usersShows';
|
||||
|
||||
const KEY = ['show-state'];
|
||||
|
||||
|
||||
+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