fix: search fetch order
This commit is contained in:
1 parent
ebf599eed6
commit
6788dea0cd
2 files changed
+32
-26
No files matched your search
@@ -10,7 +10,6 @@ import { Modal } from '@/components/ui/dialog';
|
|||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||||
import useDistinctUntilChanged from '@/hooks/useDistinctUntilChanged';
|
import useDistinctUntilChanged from '@/hooks/useDistinctUntilChanged';
|
||||||
import { cn } from '@/lib/utils';
|
|
||||||
|
|
||||||
import useSearch from './useSearch';
|
import useSearch from './useSearch';
|
||||||
|
|
||||||
@@ -36,13 +35,15 @@ export const showSearchModal = create(({ onResolve }) => {
|
|||||||
{ title: 'Series', data: series, type: 'tv' as const }
|
{ title: 'Series', data: series, type: 'tv' as const }
|
||||||
].filter(({ data: { shows } }) => shows.length);
|
].filter(({ data: { shows } }) => shows.length);
|
||||||
|
|
||||||
|
const isFetched = movies.isFetched && series.isFetched;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal className='block p-0 max-w-[932px]' onClose={onResolve} scrollRef={scrollRef}>
|
<Modal className='block p-0 max-w-[932px]' onClose={onResolve} scrollRef={scrollRef}>
|
||||||
<div className='relative p-2'>
|
<div className='relative p-2'>
|
||||||
<Input
|
<Input
|
||||||
autoFocus
|
autoFocus
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
placeholder='Start entering title...'
|
placeholder='Start typing title...'
|
||||||
value={title}
|
value={title}
|
||||||
onChange={handleChangeTitle}
|
onChange={handleChangeTitle}
|
||||||
className='pr-10 focus-visible:ring-0'
|
className='pr-10 focus-visible:ring-0'
|
||||||
@@ -58,36 +59,40 @@ export const showSearchModal = create(({ onResolve }) => {
|
|||||||
<XCircle />
|
<XCircle />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{tabs.length > 1 ? (
|
{isFetched && (
|
||||||
<Tabs defaultValue='movie' className={cn('w-full px-2')}>
|
<div className='px-2'>
|
||||||
<TabsList className='grid w-full grid-cols-2'>
|
{tabs.length > 1 ? (
|
||||||
{tabs.map(({ type, title }) => (
|
<Tabs defaultValue='movie'>
|
||||||
<TabsTrigger key={type} value={type}>
|
<TabsList className='grid w-full grid-cols-2'>
|
||||||
{title}
|
{tabs.map(({ type, title }) => (
|
||||||
</TabsTrigger>
|
<TabsTrigger key={type} value={type}>
|
||||||
))}
|
{title}
|
||||||
</TabsList>
|
</TabsTrigger>
|
||||||
{tabs.map(({ data: { shows, fetchNextPage }, type }) => (
|
))}
|
||||||
<TabsContent value={type} key={type}>
|
</TabsList>
|
||||||
|
{tabs.map(({ data: { shows, fetchNextPage }, type }) => (
|
||||||
|
<TabsContent value={type} key={type}>
|
||||||
|
<List
|
||||||
|
shows={shows}
|
||||||
|
customScrollParent={scrollRef.current}
|
||||||
|
fetchNextPage={fetchNextPage}
|
||||||
|
onPreviewClose={onResolve}
|
||||||
|
/>
|
||||||
|
</TabsContent>
|
||||||
|
))}
|
||||||
|
</Tabs>
|
||||||
|
) : (
|
||||||
|
tabs.map(({ data: { shows, fetchNextPage }, type }) => (
|
||||||
<List
|
<List
|
||||||
|
key={type}
|
||||||
shows={shows}
|
shows={shows}
|
||||||
customScrollParent={scrollRef.current}
|
customScrollParent={scrollRef.current}
|
||||||
fetchNextPage={fetchNextPage}
|
fetchNextPage={fetchNextPage}
|
||||||
onPreviewClose={onResolve}
|
onPreviewClose={onResolve}
|
||||||
/>
|
/>
|
||||||
</TabsContent>
|
))
|
||||||
))}
|
)}
|
||||||
</Tabs>
|
</div>
|
||||||
) : (
|
|
||||||
tabs.map(({ data: { shows, fetchNextPage }, type }) => (
|
|
||||||
<List
|
|
||||||
key={type}
|
|
||||||
shows={shows}
|
|
||||||
customScrollParent={scrollRef.current}
|
|
||||||
fetchNextPage={fetchNextPage}
|
|
||||||
onPreviewClose={onResolve}
|
|
||||||
/>
|
|
||||||
))
|
|
||||||
)}
|
)}
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -175,6 +175,7 @@ const Modal: React.FC<{
|
|||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<DialogContent style={style} scrollRef={scrollRef} forceMount onClose={handleClose} className={className}>
|
<DialogContent style={style} scrollRef={scrollRef} forceMount onClose={handleClose} className={className}>
|
||||||
{children}
|
{children}
|
||||||
|
<DialogDescription />
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user