From 87b053a283100f68a901222578a4dcd421c11a4a Mon Sep 17 00:00:00 2001 From: Kelvin Date: Fri, 10 Jan 2025 02:07:10 -0300 Subject: [PATCH] commented unused const --- .../src/pages/catalogue/catalogue.tsx | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/renderer/src/pages/catalogue/catalogue.tsx b/src/renderer/src/pages/catalogue/catalogue.tsx index aca21f65..0e142b45 100644 --- a/src/renderer/src/pages/catalogue/catalogue.tsx +++ b/src/renderer/src/pages/catalogue/catalogue.tsx @@ -33,8 +33,8 @@ const filterCategoryColors = { }; const PAGE_SIZE = 20; -const TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM = 10 -const LIMIT_SCROLL_TO_DISAPEAR_GO_UP_BUTTOM = 225 +const TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM = 10; +// const LIMIT_SCROLL_TO_DISAPEAR_GO_UP_BUTTOM = 225; export default function Catalogue() { const abortControllerRef = useRef(null); @@ -50,8 +50,8 @@ export default function Catalogue() { const [isLoading, setIsLoading] = useState(true); const [results, setResults] = useState([]); - - const [wantGoUpButtonIsVisible, setWantGoUpButtonIsVisible] = useState(false) + + const [wantGoUpButtonIsVisible, setWantGoUpButtonIsVisible] = useState(false); const [itemsCount, setItemsCount] = useState(0); @@ -85,19 +85,21 @@ export default function Catalogue() { ).current; useEffect(() => { - results.length > 0 && results.length <= TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM ? setWantGoUpButtonIsVisible(true) : setWantGoUpButtonIsVisible(false) - console.log(cataloguePageRef.current?.scrollTop) - }, [results]) + results.length > 0 && results.length <= TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM + ? setWantGoUpButtonIsVisible(true) + : setWantGoUpButtonIsVisible(false); + console.log(cataloguePageRef.current?.scrollTop); + }, [results]); useEffect(() => { const handleScroll = () => { if (cataloguePageRef.current) { - console.log(cataloguePageRef.current.scrollTop) + console.log(cataloguePageRef.current.scrollTop); // setScrollPosition(cataloguePageRef.current.scrollTop); } }; - if(cataloguePageRef.current){ + if (cataloguePageRef.current) { cataloguePageRef.current.addEventListener("scroll", handleScroll); } @@ -112,7 +114,7 @@ export default function Catalogue() { abortControllerRef.current?.abort(); debouncedSearch(filters, PAGE_SIZE, (page - 1) * PAGE_SIZE); - + return () => { debouncedSearch.cancel(); }; @@ -257,14 +259,14 @@ export default function Catalogue() { ]); const handleWantGoUpButtonClick = () => { - if(cataloguePageRef.current){ + if (cataloguePageRef.current) { cataloguePageRef.current.scrollTo({ top: 0, - behavior: 'smooth' - }) - setWantGoUpButtonIsVisible(false) + behavior: "smooth", + }); + setWantGoUpButtonIsVisible(false); } - } + }; return (
@@ -370,18 +372,15 @@ export default function Catalogue() {
{wantGoUpButtonIsVisible && ( -
-
)} -