refactoring: improvements for lighthouse
This commit is contained in:
1 parent
f2f242a684
commit
38aebcbe28
27 files changed
+119
-80
No files matched your search
+1
-1
@@ -213,7 +213,7 @@ export const credits = async ({
|
|||||||
showId,
|
showId,
|
||||||
showType = 'movie'
|
showType = 'movie'
|
||||||
}: {
|
}: {
|
||||||
showId: Show['id'];
|
showId?: Show['id'];
|
||||||
showType?: Show['type'];
|
showType?: Show['type'];
|
||||||
}): Promise<Array<Actor>> => {
|
}): Promise<Array<Actor>> => {
|
||||||
return http
|
return http
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ const Random = async () => {
|
|||||||
|
|
||||||
await queryClient.prefetchInfiniteQuery({
|
await queryClient.prefetchInfiniteQuery({
|
||||||
queryKey: ['random-movie'],
|
queryKey: ['random-movie'],
|
||||||
queryFn: () => randomMovies(),
|
queryFn: randomMovies,
|
||||||
initialPageParam: '1'
|
initialPageParam: '1'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
import { popularMovies } from '@/api';
|
import { popularMovies } from '@/api';
|
||||||
import useInfiniteList from '@/hooks/useInfiniteList';
|
import useInfiniteList from '@/hooks/useInfiniteList';
|
||||||
|
|
||||||
const usePopular = () => useInfiniteList({ queryKey: ['popular'], queryFn: popularMovies });
|
const usePopular = () => useInfiniteList({ suspense: true, queryKey: ['popular'], queryFn: popularMovies });
|
||||||
|
|
||||||
export default usePopular;
|
export default usePopular;
|
||||||
@@ -10,6 +10,7 @@ interface Props {
|
|||||||
|
|
||||||
const useSimilar = ({ showId, showType = 'movie' }: Props) =>
|
const useSimilar = ({ showId, showType = 'movie' }: Props) =>
|
||||||
useInfiniteList({
|
useInfiniteList({
|
||||||
|
suspense: true,
|
||||||
enabled: Boolean(showId),
|
enabled: Boolean(showId),
|
||||||
queryKey: ['similar', showId, showType],
|
queryKey: ['similar', showId, showType],
|
||||||
queryFn: ({ page }) => similarShows({ page, showId, showType })
|
queryFn: ({ page }) => similarShows({ page, showId, showType })
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import useInfiniteList from '@/hooks/useInfiniteList';
|
|||||||
|
|
||||||
const useStarring = ({ actorId }: { actorId?: string }) =>
|
const useStarring = ({ actorId }: { actorId?: string }) =>
|
||||||
useInfiniteList({
|
useInfiniteList({
|
||||||
|
suspense: true,
|
||||||
queryKey: ['starring', actorId],
|
queryKey: ['starring', actorId],
|
||||||
enabled: Boolean(actorId),
|
enabled: Boolean(actorId),
|
||||||
queryFn: ({ page }) => topMovies({ page, starring: actorId })
|
queryFn: ({ page }) => topMovies({ page, starring: actorId })
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
import { topMovies } from '@/api';
|
import { topMovies } from '@/api';
|
||||||
import useInfiniteList from '@/hooks/useInfiniteList';
|
import useInfiniteList from '@/hooks/useInfiniteList';
|
||||||
|
|
||||||
const useTop = () => useInfiniteList({ queryKey: ['top'], queryFn: topMovies });
|
const useTop = () => useInfiniteList({ suspense: true, queryKey: ['top'], queryFn: topMovies });
|
||||||
|
|
||||||
export default useTop;
|
export default useTop;
|
||||||
+1
-4
@@ -15,10 +15,7 @@ export const metadata: Metadata = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const viewport: Viewport = {
|
export const viewport: Viewport = {
|
||||||
width: 'device-width',
|
width: 'device-width'
|
||||||
initialScale: 1,
|
|
||||||
maximumScale: 1,
|
|
||||||
userScalable: false
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const font = Poppins({ subsets: ['latin'], weight: ['400', '500', '600'] });
|
const font = Poppins({ subsets: ['latin'], weight: ['400', '500', '600'] });
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const MobileNavigation = () => {
|
|||||||
<div className='flex md:hidden'>
|
<div className='flex md:hidden'>
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button variant='ghost' size='icon'>
|
<Button aria-label='Navigation toggle' variant='ghost' size='icon'>
|
||||||
<Menu size={19} />
|
<Menu size={19} />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ export const showSearchModal = create(({ onResolve }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const ToggleSearch = () => (
|
const ToggleSearch = () => (
|
||||||
<Button variant='ghost' size='icon' onClick={() => showSearchModal()}>
|
<Button aria-label='Search show' variant='ghost' size='icon' onClick={() => showSearchModal()}>
|
||||||
<SearchIcon size={19} />
|
<SearchIcon size={19} />
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ const ThemeToggle = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
|
aria-label='Toggle theme'
|
||||||
variant='ghost'
|
variant='ghost'
|
||||||
size='icon'
|
size='icon'
|
||||||
onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}
|
onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ const User = () => {
|
|||||||
return (
|
return (
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button variant='ghost' size='icon'>
|
<Button aria-label='Account menu' variant='ghost' size='icon'>
|
||||||
<UserRound size={20} />
|
<UserRound size={20} />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const Actions = ({ onClose, show, className }: Props) => {
|
|||||||
return (
|
return (
|
||||||
<div className={cn('flex gap-2 flex-wrap md:flex-grow-0 flex-grow', className)}>
|
<div className={cn('flex gap-2 flex-wrap md:flex-grow-0 flex-grow', className)}>
|
||||||
<div className={cn(groupClassName, 'pointer-events-none')}>
|
<div className={cn(groupClassName, 'pointer-events-none')}>
|
||||||
<Button className={leftClassName} variant='outline'>
|
<Button aria-label='Show rating' className={leftClassName} variant='outline'>
|
||||||
<Star size={14} />
|
<Star size={14} />
|
||||||
</Button>
|
</Button>
|
||||||
<Button className={rightClassName} variant='outline'>
|
<Button className={rightClassName} variant='outline'>
|
||||||
@@ -34,6 +34,7 @@ const Actions = ({ onClose, show, className }: Props) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className={groupClassName}>
|
<div className={groupClassName}>
|
||||||
<Button
|
<Button
|
||||||
|
aria-label='Toggle favorite'
|
||||||
className={leftClassName}
|
className={leftClassName}
|
||||||
variant='outline'
|
variant='outline'
|
||||||
disabled={toggle.list === 'favorite' && toggle.isPending}
|
disabled={toggle.list === 'favorite' && toggle.isPending}
|
||||||
@@ -42,6 +43,7 @@ const Actions = ({ onClose, show, className }: Props) => {
|
|||||||
<Heart size={14} className={cn({ 'fill-secondary-foreground': state?.favorite })} />
|
<Heart size={14} className={cn({ 'fill-secondary-foreground': state?.favorite })} />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
|
aria-label='Toggle watch list'
|
||||||
className={rightClassName}
|
className={rightClassName}
|
||||||
variant='outline'
|
variant='outline'
|
||||||
disabled={toggle.list === 'watchlist' && toggle.isPending}
|
disabled={toggle.list === 'watchlist' && toggle.isPending}
|
||||||
@@ -56,12 +58,13 @@ const Actions = ({ onClose, show, className }: Props) => {
|
|||||||
href={`/similar?id=${show.id}&title=${encodeURIComponent(show.title)}&type=${show.type}`}
|
href={`/similar?id=${show.id}&title=${encodeURIComponent(show.title)}&type=${show.type}`}
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
>
|
>
|
||||||
<Button className={leftClassName} variant='outline'>
|
<Button aria-label='Similar show' className={leftClassName} variant='outline'>
|
||||||
<Copy size={14} />
|
<Copy size={14} />
|
||||||
Similar
|
Similar
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
<Button
|
<Button
|
||||||
|
aria-label='Watch show'
|
||||||
className={cn(rightClassName, 'bg-red-600')}
|
className={cn(rightClassName, 'bg-red-600')}
|
||||||
variant='destructive'
|
variant='destructive'
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ const components: VirtuosoProps<Actor, Context>['components'] = {
|
|||||||
className='relative shrink-0 cursor-pointer snap-start self-end bg-card text-card-foreground transition-shadow hover:shadow-lg'
|
className='relative shrink-0 cursor-pointer snap-start self-end bg-card text-card-foreground transition-shadow hover:shadow-lg'
|
||||||
>
|
>
|
||||||
<Link
|
<Link
|
||||||
|
prefetch={false}
|
||||||
href={`/starring?actorId=${actor.id}&title=${encodeURIComponent(actor.name)}`}
|
href={`/starring?actorId=${actor.id}&title=${encodeURIComponent(actor.name)}`}
|
||||||
onClick={() => context?.onClick?.(actor.id.toString())}
|
onClick={() => context?.onClick?.(actor.id.toString())}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -3,13 +3,15 @@ import { useQuery } from '@tanstack/react-query';
|
|||||||
import { credits } from '@/api';
|
import { credits } from '@/api';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
showId: Show['id'];
|
showId?: Show['id'];
|
||||||
showType?: Show['type'];
|
showType?: Show['type'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const KEY = ({ showId, showType }: Props) => ['credits', showId, showType];
|
||||||
|
|
||||||
const useCredits = ({ showId, showType }: Props) => {
|
const useCredits = ({ showId, showType }: Props) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ['credits', showId, showType],
|
queryKey: KEY({ showId, showType }),
|
||||||
queryFn: () => credits({ showId, showType }),
|
queryFn: () => credits({ showId, showType }),
|
||||||
enabled: Boolean(showId)
|
enabled: Boolean(showId)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ import CaptionsMenu from './components/CaptionsMenu';
|
|||||||
import VideosMenu from './components/VideosMenu';
|
import VideosMenu from './components/VideosMenu';
|
||||||
import useSource from './useSource';
|
import useSource from './useSource';
|
||||||
|
|
||||||
|
import '@vidstack/react/player/styles/base.css';
|
||||||
|
import '@vidstack/react/player/styles/plyr/theme.css';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
magnet: string;
|
magnet: string;
|
||||||
subtitles: Source[];
|
subtitles: Source[];
|
||||||
|
|||||||
@@ -2,10 +2,17 @@ import { useQuery } from '@tanstack/react-query';
|
|||||||
|
|
||||||
import { details } from '@/api';
|
import { details } from '@/api';
|
||||||
|
|
||||||
const useDetails = ({ showId, showType = 'movie' }: { showId?: Show['id']; showType?: Show['type'] }) =>
|
interface Props {
|
||||||
|
showId?: Show['id'];
|
||||||
|
showType?: Show['type'];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const KEY = ({ showId, showType = 'movie' }: Props) => ['details', showId, showType];
|
||||||
|
|
||||||
|
const useDetails = ({ showId, showType = 'movie' }: Props) =>
|
||||||
useQuery({
|
useQuery({
|
||||||
enabled: Boolean(showId && showType),
|
enabled: Boolean(showId && showType),
|
||||||
queryKey: ['details', showId, showType],
|
queryKey: KEY({ showId, showType }),
|
||||||
queryFn: () => details({ showId: showId!, showType })
|
queryFn: () => details({ showId: showId!, showType })
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +1,55 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { FC, ForwardedRef, forwardRef, useLayoutEffect, useMemo, useRef } from 'react';
|
import { ForwardedRef, forwardRef, memo, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { Virtuoso, VirtuosoProps } from 'react-virtuoso';
|
import { Virtuoso, VirtuosoProps } from 'react-virtuoso';
|
||||||
|
|
||||||
import Poster from '@/components/Poster';
|
import Poster from '@/components/Poster';
|
||||||
import ScrollNavigation from '@/components/ScrollNavigation';
|
import ScrollNavigation from '@/components/ScrollNavigation';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
|
import { useSilentIndex } from '../../useRandomMovie';
|
||||||
|
|
||||||
interface Context {
|
interface Context {
|
||||||
onIndexChange: (index: number) => void;
|
onIndexChange: (index: number) => void;
|
||||||
gap?: number;
|
gap?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props extends Context {
|
interface Props extends Context {
|
||||||
index: number;
|
|
||||||
shows?: Show[];
|
shows?: Show[];
|
||||||
onEndReached?: () => void;
|
onEndReached?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Carousel: FC<Props> = ({ index, shows, gap = 8, onIndexChange, onEndReached }) => {
|
const Carousel = memo(
|
||||||
const initialIndex = useRef(index);
|
function Carousel({ shows, gap = 8, onIndexChange, onEndReached }: Props) {
|
||||||
|
const index = useSilentIndex();
|
||||||
|
|
||||||
|
const [isFirstRender, setIsFirstRender] = useState(true);
|
||||||
|
|
||||||
const context = useMemo(() => ({ onIndexChange, gap }), [onIndexChange, gap]);
|
const context = useMemo(() => ({ onIndexChange, gap }), [onIndexChange, gap]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='card-aspect-ratio mx-auto'>
|
<div className='card-aspect-ratio relative mx-auto'>
|
||||||
|
{isFirstRender && (
|
||||||
|
<div className='absolute left-0 top-0 size-full'>
|
||||||
|
<Poster show={shows?.[index]} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<Virtuoso
|
<Virtuoso
|
||||||
horizontalDirection
|
horizontalDirection
|
||||||
skipAnimationFrameInResizeObserver
|
skipAnimationFrameInResizeObserver
|
||||||
data={shows}
|
data={shows}
|
||||||
|
itemsRendered={() => isFirstRender && setIsFirstRender(false)}
|
||||||
context={context}
|
context={context}
|
||||||
endReached={onEndReached}
|
endReached={onEndReached}
|
||||||
initialTopMostItemIndex={initialIndex.current}
|
initialTopMostItemIndex={index}
|
||||||
components={components}
|
components={components}
|
||||||
increaseViewportBy={1000}
|
increaseViewportBy={1000}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
},
|
||||||
|
(prev, next) => prev.shows === next.shows
|
||||||
|
);
|
||||||
|
|
||||||
const components: VirtuosoProps<Show, Context>['components'] = {
|
const components: VirtuosoProps<Show, Context>['components'] = {
|
||||||
Item: ({ item, children, context, ...props }) => {
|
Item: ({ item, children, context, ...props }) => {
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ import Carousel from './components/Carousel';
|
|||||||
import useRandomMovie from './useRandomMovie';
|
import useRandomMovie from './useRandomMovie';
|
||||||
|
|
||||||
const Random = () => {
|
const Random = () => {
|
||||||
const { movies, movie, index, onIndexChange, fetchNextPage } = useRandomMovie();
|
const { movie, movies, onIndexChange, fetchNextPage } = useRandomMovie();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Preview
|
<Preview
|
||||||
show={movie}
|
show={movie}
|
||||||
className='rounded-md bg-background'
|
className='rounded-md bg-background'
|
||||||
poster={<Carousel index={index} shows={movies} onIndexChange={onIndexChange} onEndReached={fetchNextPage} />}
|
poster={<Carousel shows={movies} onIndexChange={onIndexChange} onEndReached={fetchNextPage} />}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,36 +1,37 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { startTransition, useCallback, useState } from 'react';
|
import { startTransition, useCallback } from 'react';
|
||||||
|
import { atom, getDefaultStore, useAtom } from 'jotai';
|
||||||
|
|
||||||
import { randomMovies } from '@/api';
|
import { randomMovies } from '@/api';
|
||||||
import useInfiniteList from '@/hooks/useInfiniteList';
|
import useInfiniteList from '@/hooks/useInfiniteList';
|
||||||
import useSessionRef from '@/hooks/useSessionRef';
|
|
||||||
|
const indexAtom = atom(0);
|
||||||
|
|
||||||
|
export const useSilentIndex = () => getDefaultStore().get(indexAtom);
|
||||||
|
|
||||||
const useRandomMovie = () => {
|
const useRandomMovie = () => {
|
||||||
const [indexRef, setIndexRef] = useSessionRef('random-movie-index', 0);
|
const [index, setIndex] = useAtom(indexAtom);
|
||||||
const [index, setIndex] = useState(indexRef.current);
|
|
||||||
|
|
||||||
const { shows: movies, fetchNextPage } = useInfiniteList({
|
const { shows: movies, fetchNextPage } = useInfiniteList({
|
||||||
|
suspense: true,
|
||||||
queryKey: ['random-movie'],
|
queryKey: ['random-movie'],
|
||||||
queryFn: () => randomMovies()
|
queryFn: randomMovies
|
||||||
});
|
});
|
||||||
|
|
||||||
if (movies.length && !movies[index]) {
|
if (movies.length && !movies[index]) {
|
||||||
setIndex(0);
|
setIndex(0);
|
||||||
setIndexRef(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
index,
|
|
||||||
movies,
|
|
||||||
movie: movies[index],
|
movie: movies[index],
|
||||||
|
movies,
|
||||||
fetchNextPage,
|
fetchNextPage,
|
||||||
onIndexChange: useCallback(
|
onIndexChange: useCallback(
|
||||||
(index: number) => {
|
(index: number) => {
|
||||||
setIndexRef(index);
|
|
||||||
startTransition(() => setIndex(index));
|
startTransition(() => setIndex(index));
|
||||||
},
|
},
|
||||||
[setIndexRef]
|
[setIndex]
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { QueryKey, useInfiniteQuery } from '@tanstack/react-query';
|
import { QueryKey, useInfiniteQuery, useSuspenseInfiniteQuery } from '@tanstack/react-query';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
suspense?: boolean;
|
||||||
queryKey: QueryKey;
|
queryKey: QueryKey;
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
queryFn: ({ page }: { page: string }) => Promise<Pagination<Show>>;
|
queryFn: ({ page }: { page: string }) => Promise<Pagination<Show>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const useInfiniteList = ({ queryKey, queryFn, enabled }: Props) => {
|
const useInfiniteList = ({ queryKey, queryFn, enabled, suspense }: Props) => {
|
||||||
const { data, hasNextPage, fetchNextPage, isFetched, isLoading } = useInfiniteQuery({
|
const { data, hasNextPage, fetchNextPage, isFetched, isLoading } = (
|
||||||
|
suspense ? useSuspenseInfiniteQuery : useInfiniteQuery
|
||||||
|
)({
|
||||||
enabled,
|
enabled,
|
||||||
queryKey,
|
queryKey,
|
||||||
queryFn: ({ pageParam }) => queryFn({ page: pageParam }),
|
queryFn: ({ pageParam }) => queryFn({ page: pageParam }),
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
import { MutableRefObject, useCallback, useEffect, useRef, useState } from 'react';
|
|
||||||
|
|
||||||
const useSessionRef = <T>(key: string, initialValue: T): [MutableRefObject<T>, (value: T) => void] => {
|
|
||||||
const [state] = useState(() => {
|
|
||||||
if (typeof window === 'undefined') return initialValue;
|
|
||||||
|
|
||||||
const storedValue = sessionStorage.getItem(key);
|
|
||||||
|
|
||||||
return storedValue ? JSON.parse(storedValue) : initialValue;
|
|
||||||
});
|
|
||||||
|
|
||||||
const ref = useRef(state);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const listener = () => sessionStorage.removeItem(key);
|
|
||||||
|
|
||||||
window.addEventListener('beforeunload', listener);
|
|
||||||
|
|
||||||
return () => window.removeEventListener('beforeunload', listener);
|
|
||||||
}, [key]);
|
|
||||||
|
|
||||||
const setter = useCallback(
|
|
||||||
(value: T) => {
|
|
||||||
sessionStorage.setItem(key, JSON.stringify(value));
|
|
||||||
ref.current = value;
|
|
||||||
},
|
|
||||||
[key]
|
|
||||||
);
|
|
||||||
|
|
||||||
return [ref, setter];
|
|
||||||
};
|
|
||||||
|
|
||||||
export default useSessionRef;
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import { accountStates, updateAccountStates } from '@/api';
|
|
||||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
|
import { accountStates, updateAccountStates } from '@/api';
|
||||||
|
|
||||||
import { useFavorites, useFavoritesStateToggle, useWatchList, useWatchListStateToggle } from './useLocalUsersLists';
|
import { useFavorites, useFavoritesStateToggle, useWatchList, useWatchListStateToggle } from './useLocalUsersLists';
|
||||||
import { useSession } from './useSession';
|
import { useSession } from './useSession';
|
||||||
|
|
||||||
import { KEY as USERS_SHOWS_KEY } from './useUsersShows';
|
import { KEY as USERS_SHOWS_KEY } from './useUsersShows';
|
||||||
|
|
||||||
const KEY = ['show-state'];
|
const KEY = ['show-state'];
|
||||||
@@ -49,7 +50,7 @@ export const useMutateShowState = (show: Show) => {
|
|||||||
queryClient.setQueryData<ShowState>(key, snapshot);
|
queryClient.setQueryData<ShowState>(key, snapshot);
|
||||||
},
|
},
|
||||||
onSuccess(_, { list, showType }) {
|
onSuccess(_, { list, showType }) {
|
||||||
queryClient.invalidateQueries({ queryKey: USERS_SHOWS_KEY({ list, showType }) });
|
queryClient.invalidateQueries({ queryKey: USERS_SHOWS_KEY({ list, showType }), refetchType: 'all' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -4,10 +4,10 @@ const makeQueryClient = () => {
|
|||||||
return new QueryClient({
|
return new QueryClient({
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
queries: {
|
queries: {
|
||||||
refetchOnWindowFocus: false,
|
|
||||||
staleTime: Infinity,
|
staleTime: Infinity,
|
||||||
refetchOnReconnect: false,
|
refetchOnReconnect: false,
|
||||||
refetchOnMount: false
|
refetchOnMount: false,
|
||||||
|
refetchOnWindowFocus: false
|
||||||
},
|
},
|
||||||
dehydrate: {
|
dehydrate: {
|
||||||
shouldDehydrateQuery: (query) => defaultShouldDehydrateQuery(query) || query.state.status === 'pending'
|
shouldDehydrateQuery: (query) => defaultShouldDehydrateQuery(query) || query.state.status === 'pending'
|
||||||
|
|||||||
Generated
+39
@@ -17,6 +17,7 @@
|
|||||||
"@radix-ui/react-toast": "^1.2.2",
|
"@radix-ui/react-toast": "^1.2.2",
|
||||||
"@radix-ui/react-toggle": "^1.0.3",
|
"@radix-ui/react-toggle": "^1.0.3",
|
||||||
"@tanstack/react-query": "^5.59.15",
|
"@tanstack/react-query": "^5.59.15",
|
||||||
|
"@tanstack/react-query-devtools": "^5.59.15",
|
||||||
"@vidstack/react": "^1.12.11",
|
"@vidstack/react": "^1.12.11",
|
||||||
"axios": "^1.4.0",
|
"axios": "^1.4.0",
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
@@ -2548,6 +2549,15 @@
|
|||||||
"url": "https://github.com/sponsors/tannerlinsley"
|
"url": "https://github.com/sponsors/tannerlinsley"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@tanstack/query-devtools": {
|
||||||
|
"version": "5.58.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@tanstack/query-devtools/-/query-devtools-5.58.0.tgz",
|
||||||
|
"integrity": "sha512-iFdQEFXaYYxqgrv63ots+65FGI+tNp5ZS5PdMU1DWisxk3fez5HG3FyVlbUva+RdYS5hSLbxZ9aw3yEs97GNTw==",
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/tannerlinsley"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@tanstack/react-query": {
|
"node_modules/@tanstack/react-query": {
|
||||||
"version": "5.59.15",
|
"version": "5.59.15",
|
||||||
"resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.59.15.tgz",
|
"resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.59.15.tgz",
|
||||||
@@ -2564,6 +2574,22 @@
|
|||||||
"react": "^18 || ^19"
|
"react": "^18 || ^19"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@tanstack/react-query-devtools": {
|
||||||
|
"version": "5.59.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/@tanstack/react-query-devtools/-/react-query-devtools-5.59.15.tgz",
|
||||||
|
"integrity": "sha512-rX28KTivkA2XEn3Fj9ckDtnTPY8giWYgssySSAperpVol4+th+NCij/MhLylfB+Mfg2JfCxOcwnM/fwzS8iSog==",
|
||||||
|
"dependencies": {
|
||||||
|
"@tanstack/query-devtools": "5.58.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/tannerlinsley"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@tanstack/react-query": "^5.59.15",
|
||||||
|
"react": "^18 || ^19"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/js-cookie": {
|
"node_modules/@types/js-cookie": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-3.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-3.0.3.tgz",
|
||||||
@@ -8952,6 +8978,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.59.13.tgz",
|
"resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.59.13.tgz",
|
||||||
"integrity": "sha512-Oou0bBu/P8+oYjXsJQ11j+gcpLAMpqW42UlokQYEz4dE7+hOtVO9rVuolJKgEccqzvyFzqX4/zZWY+R/v1wVsQ=="
|
"integrity": "sha512-Oou0bBu/P8+oYjXsJQ11j+gcpLAMpqW42UlokQYEz4dE7+hOtVO9rVuolJKgEccqzvyFzqX4/zZWY+R/v1wVsQ=="
|
||||||
},
|
},
|
||||||
|
"@tanstack/query-devtools": {
|
||||||
|
"version": "5.58.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@tanstack/query-devtools/-/query-devtools-5.58.0.tgz",
|
||||||
|
"integrity": "sha512-iFdQEFXaYYxqgrv63ots+65FGI+tNp5ZS5PdMU1DWisxk3fez5HG3FyVlbUva+RdYS5hSLbxZ9aw3yEs97GNTw=="
|
||||||
|
},
|
||||||
"@tanstack/react-query": {
|
"@tanstack/react-query": {
|
||||||
"version": "5.59.15",
|
"version": "5.59.15",
|
||||||
"resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.59.15.tgz",
|
"resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.59.15.tgz",
|
||||||
@@ -8960,6 +8991,14 @@
|
|||||||
"@tanstack/query-core": "5.59.13"
|
"@tanstack/query-core": "5.59.13"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@tanstack/react-query-devtools": {
|
||||||
|
"version": "5.59.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/@tanstack/react-query-devtools/-/react-query-devtools-5.59.15.tgz",
|
||||||
|
"integrity": "sha512-rX28KTivkA2XEn3Fj9ckDtnTPY8giWYgssySSAperpVol4+th+NCij/MhLylfB+Mfg2JfCxOcwnM/fwzS8iSog==",
|
||||||
|
"requires": {
|
||||||
|
"@tanstack/query-devtools": "5.58.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@types/js-cookie": {
|
"@types/js-cookie": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-3.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-3.0.3.tgz",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"@radix-ui/react-toast": "^1.2.2",
|
"@radix-ui/react-toast": "^1.2.2",
|
||||||
"@radix-ui/react-toggle": "^1.0.3",
|
"@radix-ui/react-toggle": "^1.0.3",
|
||||||
"@tanstack/react-query": "^5.59.15",
|
"@tanstack/react-query": "^5.59.15",
|
||||||
|
"@tanstack/react-query-devtools": "^5.59.15",
|
||||||
"@vidstack/react": "^1.12.11",
|
"@vidstack/react": "^1.12.11",
|
||||||
"axios": "^1.4.0",
|
"axios": "^1.4.0",
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { FC, ReactNode } from 'react';
|
import { FC, ReactNode } from 'react';
|
||||||
import ModalContainer from 'react-modal-promise';
|
import ModalContainer from 'react-modal-promise';
|
||||||
import { QueryClientProvider } from '@tanstack/react-query';
|
import { QueryClientProvider } from '@tanstack/react-query';
|
||||||
|
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
||||||
|
|
||||||
import { Toaster } from '@/components/ui/toaster';
|
import { Toaster } from '@/components/ui/toaster';
|
||||||
import getQueryClient from '@/lib/queryClient';
|
import getQueryClient from '@/lib/queryClient';
|
||||||
@@ -22,6 +23,7 @@ const Providers: FC<Props> = ({ children, theme }) => {
|
|||||||
<ThemeProvider theme={theme}>{children}</ThemeProvider>
|
<ThemeProvider theme={theme}>{children}</ThemeProvider>
|
||||||
<ModalContainer exitTimeout={500} enterTimeout={0} />
|
<ModalContainer exitTimeout={500} enterTimeout={0} />
|
||||||
<Toaster />
|
<Toaster />
|
||||||
|
<ReactQueryDevtools initialIsOpen={true} />
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
|
|
||||||
@import '@vidstack/react/player/styles/base.css';
|
|
||||||
@import '@vidstack/react/player/styles/plyr/theme.css';
|
|
||||||
|
|
||||||
@layer base {
|
@layer base {
|
||||||
:root {
|
:root {
|
||||||
--background: 0 0% 100%;
|
--background: 0 0% 100%;
|
||||||
|
|||||||
Reference in new issue
Block a user