refactoring: improved types
This commit is contained in:
1 parent
272178d668
commit
5c42608e99
10 files changed
+93
-88
No files matched your search
@@ -16,14 +16,13 @@ import showHostManagerModal from './HostManager';
|
||||
import useTorrents from './useTorrents';
|
||||
|
||||
interface Props extends InstanceProps<void> {
|
||||
showId: Show['id'];
|
||||
showType: Show['type'];
|
||||
imdbID: string;
|
||||
title: string;
|
||||
year: number;
|
||||
backdrop: string;
|
||||
}
|
||||
|
||||
const showTorrentsModal = create(({ title, year, showType, showId, backdrop, onResolve }: Props) => {
|
||||
const showTorrentsModal = create(({ title, year, imdbID, backdrop, onResolve }: Props) => {
|
||||
const isMobile = matchMedia('(max-width: 600px)').matches;
|
||||
const prefix = usePrefix();
|
||||
const [sort, setSort] = useState<Sort>(Sort.seeds);
|
||||
@@ -39,8 +38,7 @@ const showTorrentsModal = create(({ title, year, showType, showId, backdrop, onR
|
||||
} = useTorrents({
|
||||
query,
|
||||
sort,
|
||||
showId,
|
||||
showType,
|
||||
imdbID,
|
||||
key,
|
||||
queryFn
|
||||
});
|
||||
|
||||
@@ -5,22 +5,20 @@ import { Sort } from '@/api/parsers';
|
||||
const useTorrents = ({
|
||||
query,
|
||||
sort,
|
||||
showId,
|
||||
showType,
|
||||
imdbID,
|
||||
key,
|
||||
queryFn
|
||||
}: {
|
||||
showId: Show['id'];
|
||||
showType: Show['type'];
|
||||
key: string;
|
||||
query: string;
|
||||
sort: Sort;
|
||||
queryFn: (params: { query: string; sort: Sort; showId: Show['id']; showType: Show['type'] }) => Promise<Torrent[]>;
|
||||
imdbID: string;
|
||||
queryFn: (params: { query: string; sort: Sort; imdbID: string; }) => Promise<Torrent[]>;
|
||||
}) => {
|
||||
return useQuery({
|
||||
enabled: Boolean(query),
|
||||
queryKey: [key, query, sort, showId, showType],
|
||||
queryFn: () => queryFn({ query, sort, showId, showType })
|
||||
queryKey: [key, query, sort, imdbID],
|
||||
queryFn: () => queryFn({ query, sort, imdbID })
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user