fixed build performance issues; optimized queries
This commit is contained in:
@@ -5,7 +5,7 @@ import { Combobox, ComboboxProps } from "../combobox";
|
||||
import { Icons } from "../icons";
|
||||
|
||||
function CategorySelect(props: Partial<ComboboxProps>) {
|
||||
const { data: categories } = api.category.getAll.useQuery();
|
||||
const { data: categories } = api.category.getMany.useQuery();
|
||||
return (
|
||||
<Combobox
|
||||
{...(props as ComboboxProps)}
|
||||
|
||||
@@ -9,8 +9,8 @@ export const CATEGORY_GRID_CLASS =
|
||||
function CategoryGrid({ categories }: { categories: Category[] }) {
|
||||
return (
|
||||
<menu className={CATEGORY_GRID_CLASS}>
|
||||
{categories.map((category) => (
|
||||
<li key={category.id}>
|
||||
{categories.map((category, idx) => (
|
||||
<li key={idx}>
|
||||
<CategoryCard {...category} />
|
||||
</li>
|
||||
))}
|
||||
|
||||
@@ -18,6 +18,9 @@ export default function InfiniteCategoryGrid() {
|
||||
},
|
||||
{
|
||||
getNextPageParam: (lastPage) => lastPage.nextCursor,
|
||||
staleTime: 60 * 4 * 1000, // 4 minutes stale time
|
||||
refetchOnMount: false, // Prevents unnecessary refetching
|
||||
refetchOnWindowFocus: false, // Avoids refetch when switching tabs
|
||||
},
|
||||
);
|
||||
// Calculate all visible items across all loaded pages
|
||||
|
||||
Reference in New Issue
Block a user