diff --git a/components/Movie/List.tsx b/components/Movie/List.tsx
index 52d381e..bd6dfcc 100644
--- a/components/Movie/List.tsx
+++ b/components/Movie/List.tsx
@@ -2,8 +2,7 @@ import { FC, Fragment, useLayoutEffect, useState } from 'react';
import { motion } from 'framer-motion';
import Card from '@/components/Movie/Card';
-import Preview from '@/components/Movie/Preview';
-import { Modal } from '@/components/ui/dialog';
+import { showPreviewModal } from '@/components/Movie/Preview';
import filterUnknownMovies from '@/lib/filterUnknownMovies';
interface Props {
@@ -32,7 +31,6 @@ const item = {
};
const List: FC
= ({ pages, hasNextPage, fetchNextPage, withBottomGap = true, onPreviewClose }) => {
- const [movie, setMovie] = useState(null);
const [loader, setLoader] = useState();
useLayoutEffect(() => {
@@ -74,7 +72,7 @@ const List: FC = ({ pages, hasNextPage, fetchNextPage, withBottomGap = tr
className='flex cursor-pointer'
ref={isAnchor ? (element) => setLoader(element!) : undefined}
>
- setMovie(movie)} />
+ showPreviewModal({ movie, onClose: onPreviewClose })} />
);
})}
@@ -82,21 +80,6 @@ const List: FC = ({ pages, hasNextPage, fetchNextPage, withBottomGap = tr
))}
{withBottomGap && }
- setMovie(null)} className='block p-0'>
- {movie && (
- {
- setMovie(null);
- window.scrollTo({ top: 0, behavior: 'smooth' });
- onPreviewClose?.();
- }}
- />
- )}
-
>
);
};
diff --git a/components/Movie/Preview/index.tsx b/components/Movie/Preview/index.tsx
index 0f857cd..d65fd24 100644
--- a/components/Movie/Preview/index.tsx
+++ b/components/Movie/Preview/index.tsx
@@ -1,8 +1,10 @@
'use client';
import { FC, ReactNode } from 'react';
+import { create, InstanceProps } from 'react-modal-promise';
import Credits from '@/components/Movie/components/Credits';
+import { Modal } from '@/components/ui/dialog';
import { Separator } from '@/components/ui/separator';
import { cn } from '@/lib/utils';
@@ -16,16 +18,16 @@ interface Props {
className?: string;
onClose?: () => void;
children?: ReactNode;
- renderCard?: () => ReactNode;
+ card?: ReactNode;
}
-const Preview: FC = ({ movie, className, onClose, children, renderCard, fit }) => {
+const Preview: FC = ({ movie, className, onClose, children, card, fit }) => {
if (!movie) return null;
return (
- {renderCard?.() ||
}
+ {card ||
}
{children &&
{children}
}
@@ -42,4 +44,19 @@ const Preview: FC
= ({ movie, className, onClose, children, renderCard, f
);
};
+export const showPreviewModal = create(({ onResolve, onClose, movie }: Props & InstanceProps) => (
+
+ {
+ window.scrollTo({ top: 0, behavior: 'smooth' });
+ onClose?.();
+ onResolve();
+ }}
+ />
+
+));
+
export default Preview;
diff --git a/components/Movie/components/Torrents/index.tsx b/components/Movie/components/Torrents/index.tsx
index 1f2339c..3f092cd 100644
--- a/components/Movie/components/Torrents/index.tsx
+++ b/components/Movie/components/Torrents/index.tsx
@@ -51,10 +51,10 @@ const TableHeadSortable = ({
const hostAtom = atomWithStorage('magnet-host', '');
-const showHostManagerModal = create(({ onResolve, isOpen }) => {
+const showHostManagerModal = create(({ onResolve }) => {
const [host, setHost] = useAtom(hostAtom);
return (
- onResolve()}>
+
{
);
});
-const Torrents: FC = ({ title, year, isOpen, onResolve }) => {
+const Torrents: FC = ({ title, year, onResolve }) => {
const hosts = useAtomValue(hostAtom);
const [sorting, setSorting] = useState({ by: ORDER.seeders });
const [withYear, setWithYear] = useState(true);
@@ -87,7 +87,7 @@ const Torrents: FC = ({ title, year, isOpen, onResolve }) => {
};
return (
- onResolve()}>
+
diff --git a/components/Movie/components/Trailer/index.tsx b/components/Movie/components/Trailer/index.tsx
index a79219f..6923113 100644
--- a/components/Movie/components/Trailer/index.tsx
+++ b/components/Movie/components/Trailer/index.tsx
@@ -13,15 +13,11 @@ interface Props {
children?: ({ onPlay, disabled }: { onPlay: () => void; disabled: boolean }) => ReactNode;
}
-const Trailer: FC<{ trailerKey?: string } & InstanceProps> = ({ trailerKey, onResolve, isOpen }) => {
+const Trailer: FC<{ trailerKey?: string } & InstanceProps> = ({ trailerKey, onResolve }) => {
if (!trailerKey) return;
return (
- onResolve()}
- isOpen={isOpen}
- >
+