fixed build performance issues; optimized queries

This commit is contained in:
2025-03-15 20:31:38 +01:00
parent cff9dad54c
commit 324451e082
27 changed files with 289 additions and 208 deletions
+1 -1
View File
@@ -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