diff --git a/app/(site)/starring/page.tsx b/app/(site)/starring/page.tsx
index 691d80e..df5a71d 100644
--- a/app/(site)/starring/page.tsx
+++ b/app/(site)/starring/page.tsx
@@ -22,5 +22,3 @@ export default async function Starring({ searchParams }: { searchParams: Record<
);
}
-
-export const revalidate = 3600;
diff --git a/app/(site)/starring/useStarring.ts b/app/(site)/starring/useStarring.ts
index bf2632b..ea414a8 100644
--- a/app/(site)/starring/useStarring.ts
+++ b/app/(site)/starring/useStarring.ts
@@ -7,9 +7,7 @@ const useStarring = ({ actorId }: { actorId?: string }) =>
useInfiniteList({
queryKey: ['starring', actorId],
enabled: Boolean(actorId),
- queryFn: ({ page }) => {
- return topMovies({ page, starring: actorId });
- }
+ queryFn: ({ page }) => topMovies({ page, starring: actorId })
});
export default useStarring;
diff --git a/app/layout.tsx b/app/layout.tsx
index e5c0690..b83ed53 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -32,9 +32,7 @@ const RootLayout = ({ children }: { children: ReactNode }) => {
-
-
-
+
{children}
diff --git a/components/Header/components/Search/index.tsx b/components/Header/components/Search/index.tsx
index 7803955..dac0ec4 100644
--- a/components/Header/components/Search/index.tsx
+++ b/components/Header/components/Search/index.tsx
@@ -17,6 +17,7 @@ export const showSearchModal = create(({ onResolve }) => {
const [title, setTitle] = useState('');
const scrollRef = useRef(null) as MutableRefObject;
const inputRef = useRef(null);
+ const isFetchedRef = useRef(false);
const query = useDistinctUntilChanged(title);
@@ -35,7 +36,13 @@ export const showSearchModal = create(({ onResolve }) => {
{ title: 'Series', data: series, type: 'tv' as const }
].filter(({ data: { shows } }) => shows.length);
- const isFetched = movies.isFetched && series.isFetched;
+ if (!isFetchedRef.current && movies.isFetched && series.isFetched) {
+ isFetchedRef.current = true;
+ }
+
+ if (!query) {
+ isFetchedRef.current = false;
+ }
return (
@@ -59,7 +66,7 @@ export const showSearchModal = create(({ onResolve }) => {
- {isFetched && (
+ {isFetchedRef.current && (
{tabs.length > 1 ? (
diff --git a/components/Header/components/Search/useSearch.ts b/components/Header/components/Search/useSearch.ts
index 60bf068..c80f106 100644
--- a/components/Header/components/Search/useSearch.ts
+++ b/components/Header/components/Search/useSearch.ts
@@ -1,11 +1,29 @@
+import { useRef } from 'react';
+
import { search } from '@/api';
import useInfiniteList from '@/hooks/useInfiniteList';
-const useSearch = ({ query, type }: { query: string; type: Show['type'] }) =>
- useInfiniteList({
+const useSearch = ({ query, type }: { query: string; type: Show['type'] }) => {
+ const previous = useRef([]);
+
+ const infiniteQuery = useInfiniteList({
queryKey: ['search', query, type],
queryFn: ({ page }) => search({ query, page, type }),
enabled: Boolean(query)
});
+ if (infiniteQuery.isFetched) {
+ previous.current = infiniteQuery.shows;
+ }
+
+ if (!query) {
+ previous.current = [];
+ }
+
+ return {
+ ...infiniteQuery,
+ shows: infiniteQuery.isLoading ? previous.current : infiniteQuery.shows
+ };
+};
+
export default useSearch;
diff --git a/components/Header/index.tsx b/components/Header/index.tsx
index 4054a64..5298ca1 100644
--- a/components/Header/index.tsx
+++ b/components/Header/index.tsx
@@ -2,13 +2,23 @@ import { FC } from 'react';
import Link from 'next/link';
import { Badge } from '@/components/ui/badge';
+import { cn } from '@/lib/utils';
import { DesktopNavigation, MobileNavigation } from './components/Navigation';
import ToggleSearch from './components/Search';
import ToggleTheme from './components/ThemeToggle';
-const Header: FC = () => (
-
+interface Props {
+ className?: string;
+}
+
+const Header: FC = ({ className }) => (
+