diff --git a/components/Movie/components/Torrents/HostManager.tsx b/components/Movie/components/Torrents/HostManager.tsx index b77e716..1eeafc4 100644 --- a/components/Movie/components/Torrents/HostManager.tsx +++ b/components/Movie/components/Torrents/HostManager.tsx @@ -2,20 +2,21 @@ import { create, InstanceProps } from 'react-modal-promise'; import { Modal } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; -import { useHost, useSetHost } from '@/hooks/useMagnetHosts'; +import { usePrefix, useSetPrefix } from '@/hooks/useMagnetHosts'; const showHostManagerModal = create>(({ onResolve, onReject }) => { - const host = useHost(); - const setHost = useSetHost(); + const prefix = usePrefix(); + const setPrefix = useSetPrefix(); + return ( setHost(value)} - onKeyDown={({ key }) => key === 'Enter' && onResolve(host)} + onChange={({ target: { value } }) => setPrefix(value)} + onKeyDown={({ key }) => key === 'Enter' && onResolve(prefix)} /> ); diff --git a/components/Movie/components/Torrents/index.tsx b/components/Movie/components/Torrents/index.tsx index d8a14aa..fb7fafe 100644 --- a/components/Movie/components/Torrents/index.tsx +++ b/components/Movie/components/Torrents/index.tsx @@ -1,13 +1,13 @@ -import React, { Dispatch, FC, SetStateAction, useState } from 'react'; +import React, { Dispatch, FC, Fragment, SetStateAction, useState } from 'react'; import { create, InstanceProps } from 'react-modal-promise'; import { ArrowDownIcon, CaretSortIcon } from '@radix-ui/react-icons'; -import { Cast, Loader, Magnet } from 'lucide-react'; +import { Cast, Copy,Loader, Magnet } from 'lucide-react'; import useTorrents from '@/app/(site)/useTorrents'; import { Modal } from '@/components/ui/dialog'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'; import { Toggle } from '@/components/ui/toggle'; -import { useCastMagnet, useHost, useSetHost } from '@/hooks/useMagnetHosts'; +import { useCastMagnet, usePrefix } from '@/hooks/useMagnetHosts'; import { ORDER } from '@/lib/api/parsers/pirate-bay'; import showHostManagerModal from './HostManager'; @@ -41,7 +41,7 @@ const TableHeadSortable = ({ } className='cursor-pointer select-none px-2' > -
+
{title} {value.by === by ? : }
@@ -50,7 +50,8 @@ const TableHeadSortable = ({ }; const Torrents: FC = ({ title, year, onResolve }) => { - const host = useHost(); + const isMobile = matchMedia('(max-width: 600px)').matches; + const prefix = usePrefix(); const [sorting, setSorting] = useState({ by: ORDER.seeders }); const [withYear, setWithYear] = useState(true); @@ -68,54 +69,65 @@ const Torrents: FC = ({ title, year, onResolve }) => { - {title}{' '} - setWithYear((withYear) => !withYear)} - > - {year} - +
+ {title} + setWithYear((withYear) => !withYear)} + > + {year} + +
- Title + {!isMobile && Title} - showHostManagerModal()}> - Magnet - + showHostManagerModal()} />
{torrents?.map((torrent) => ( - - {torrent.title} - -
{torrent.size}
-
- {torrent.seeders} - -
- {host ? ( - { - event.preventDefault(); - cast(torrent.magnet!); - }} - className='flex items-center justify-center h-8 w-8 border rounded-lg' - > - - - ) : ( + + {isMobile && ( + + + {torrent.title} + + + )} + + {!isMobile && {torrent.title}} + +
{torrent.size}
+
+ {torrent.seeders} + +
- )} -
-
-
+
navigator.clipboard.writeText(torrent.magnet)} + > + +
+ {prefix && !prefix.includes('{host}') && ( +
cast(torrent.magnet!)} + className='flex items-center justify-center h-8 w-8 border rounded-lg cursor-pointer' + > + +
+ )} +
+
+
+ ))} {isLoading && ( diff --git a/components/Movie/components/Trailer/index.tsx b/components/Movie/components/Trailer/index.tsx index b6b9946..84ebd18 100644 --- a/components/Movie/components/Trailer/index.tsx +++ b/components/Movie/components/Trailer/index.tsx @@ -17,11 +17,10 @@ const Trailer: FC<{ trailerKey?: string } & InstanceProps> = ({ trailerKey if (!trailerKey) return; return ( - +