From 074eca52978dda6ebe05f7ed645970df54ad9d5b Mon Sep 17 00:00:00 2001 From: franco sanchez Date: Wed, 21 Aug 2024 13:48:35 -0300 Subject: [PATCH] chore: some design improvements --- src/components/AllBooks.tsx | 4 ++-- src/components/aside/AboutCategories.tsx | 1 + src/hooks/queries.ts | 8 +++++--- .../{useScrollRestoration.ts => useScrollYRestoration.ts} | 2 +- src/pages/Search.tsx | 4 ++-- 5 files changed, 11 insertions(+), 8 deletions(-) rename src/hooks/{useScrollRestoration.ts => useScrollYRestoration.ts} (91%) diff --git a/src/components/AllBooks.tsx b/src/components/AllBooks.tsx index 71719c6..c952956 100644 --- a/src/components/AllBooks.tsx +++ b/src/components/AllBooks.tsx @@ -13,7 +13,7 @@ import { useInView } from 'react-intersection-observer'; import { CardType } from '@components/types'; import { useBooksPaginate } from '@hooks/queries'; -import { useScrollRestoration } from '@hooks/useScrollRestoration'; +import { useScrollYRestoration } from '@hooks/useScrollYRestoration'; import { MySimpleGrid } from '@components/ui/MySimpleGrid'; import { Card } from '@components/cards/Card'; import { Aside } from '@components/aside/Aside'; @@ -27,7 +27,7 @@ export function AllBooks() { useBooksPaginate(); let fetchingNextPageUI; - useScrollRestoration(isPending); // Restablece la posición del scroll al volver de la vista del libro + useScrollYRestoration(isPending); // Restablece la posición del scroll al volver de la vista del libro useEffect(() => { let isMounted = true; diff --git a/src/components/aside/AboutCategories.tsx b/src/components/aside/AboutCategories.tsx index 7292f3a..a106aa4 100644 --- a/src/components/aside/AboutCategories.tsx +++ b/src/components/aside/AboutCategories.tsx @@ -20,6 +20,7 @@ export function AboutCategories({ category }: any) { fontSize='sm' maxH='250px' overflow='auto' + pr='1' sx={{ '&::-webkit-scrollbar': { width: '7px', diff --git a/src/hooks/queries.ts b/src/hooks/queries.ts index f3363ad..b895308 100644 --- a/src/hooks/queries.ts +++ b/src/hooks/queries.ts @@ -212,9 +212,10 @@ function useCheckUser(id: string | undefined) { return useQuery({ queryKey: [keys.checkUser, id], queryFn: () => getCheckUser(id), + gcTime: 24 * 3600 * 1000, enabled: false, refetchOnWindowFocus: false, - retry: 1, + retry: false, }); } @@ -222,8 +223,9 @@ function useUserData(id: string | undefined) { return useQuery({ queryKey: [keys.userData, id], queryFn: () => getCheckUser(id), - staleTime: 0, - retry: 4, + gcTime: 24 * 3600 * 1000, + staleTime: 24 * 3600 * 1000, + retry: 2, }); } diff --git a/src/hooks/useScrollRestoration.ts b/src/hooks/useScrollYRestoration.ts similarity index 91% rename from src/hooks/useScrollRestoration.ts rename to src/hooks/useScrollYRestoration.ts index 5285924..ea3b119 100644 --- a/src/hooks/useScrollRestoration.ts +++ b/src/hooks/useScrollYRestoration.ts @@ -1,7 +1,7 @@ import { useLayoutEffect } from 'react'; import { useLocation } from 'react-router-dom'; -export function useScrollRestoration(loading: boolean) { +export function useScrollYRestoration(loading: boolean) { const location = useLocation(); useLayoutEffect(() => { diff --git a/src/pages/Search.tsx b/src/pages/Search.tsx index ea29d82..fc6151e 100644 --- a/src/pages/Search.tsx +++ b/src/pages/Search.tsx @@ -21,7 +21,7 @@ import { import { Card } from '@components/cards/Card'; import { CardType } from '@components/types'; import { useFilter, useFilterPaginated } from '@hooks/queries'; -import { useScrollRestoration } from '@hooks/useScrollRestoration'; +import { useScrollYRestoration } from '@hooks/useScrollYRestoration'; import { ContainerTitle } from '@components/layout/ContainerTitle'; import { MySimpleGrid } from '@components/ui/MySimpleGrid'; import { MainHead } from '@components/layout/Head'; @@ -85,7 +85,7 @@ export default function Search() { } const results = getNormalizedResults(); - useScrollRestoration(isPendingPaginated); // Restablece la posición del scroll al volver de la vista del libro + useScrollYRestoration(isPendingPaginated); // Restablece la posición del scroll al volver de la vista del libro useEffect(() => { let isMounted = true;