feat: added torrents and similar for every movie

This commit is contained in:
ner committed 2023-08-18 12:36:10 +03:00
1 parent ada725072f
commit 8bff4d6d80
16 files changed
+91 -117

No files matched your search

+6 -20
View File
@@ -1,29 +1,15 @@
import { useMemo } from 'react';
import { useQuery } from '@tanstack/react-query';
import { ORDER } from '../api/torrents/parsers/pirate-bay';
import API from './api';
const useTorrents = ({ query }: { query: string }) => {
const { data: trackersTorrents, ...tracker } = useQuery({
const useTorrents = ({ query, order }: { query: string; order: ORDER }) => {
return useQuery({
enabled: Boolean(query),
queryKey: ['tracker', query],
queryFn: () => API.torrents.tracker({ query })
queryKey: ['pirate-bay', query, order],
queryFn: () => API.torrents.pirateBay({ query, order })
});
const { data: piratesTorrents, ...pirateBay } = useQuery({
enabled: Boolean(query),
queryKey: ['pirate-bay', query],
queryFn: () => API.torrents.pirateBay({ query })
});
return {
torrents: useMemo(
() => [...(trackersTorrents || []), ...(piratesTorrents || [])],
[trackersTorrents, piratesTorrents]
),
isLoading: tracker.isLoading || pirateBay.isLoading,
isFetched: tracker.isFetched && pirateBay.isFetched
};
};
export default useTorrents;