From bff430602d85a690d3b9f51e8405ca35c05f8012 Mon Sep 17 00:00:00 2001 From: Kelvin Date: Fri, 10 Jan 2025 02:04:10 -0300 Subject: [PATCH 1/5] placed buttom and initial logic --- .../src/pages/catalogue/catalogue.tsx | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/pages/catalogue/catalogue.tsx b/src/renderer/src/pages/catalogue/catalogue.tsx index 14a9f4d64..aca21f651 100644 --- a/src/renderer/src/pages/catalogue/catalogue.tsx +++ b/src/renderer/src/pages/catalogue/catalogue.tsx @@ -21,6 +21,8 @@ import { useCatalogue } from "@renderer/hooks/use-catalogue"; import { GameItem } from "./game-item"; import { FilterItem } from "./filter-item"; import { debounce } from "lodash-es"; +import { Button } from "@renderer/components"; +import { ArrowUpIcon } from "@primer/octicons-react"; const filterCategoryColors = { genres: "hsl(262deg 50% 47%)", @@ -31,6 +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 export default function Catalogue() { const abortControllerRef = useRef(null); @@ -46,6 +50,8 @@ export default function Catalogue() { const [isLoading, setIsLoading] = useState(true); const [results, setResults] = useState([]); + + const [wantGoUpButtonIsVisible, setWantGoUpButtonIsVisible] = useState(false) const [itemsCount, setItemsCount] = useState(0); @@ -78,13 +84,35 @@ export default function Catalogue() { }, 500) ).current; + useEffect(() => { + 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) + // setScrollPosition(cataloguePageRef.current.scrollTop); + } + }; + + if(cataloguePageRef.current){ + cataloguePageRef.current.addEventListener("scroll", handleScroll); + } + + return () => { + cataloguePageRef.current?.removeEventListener("scroll", handleScroll); + }; + }, []); + useEffect(() => { setResults([]); setIsLoading(true); abortControllerRef.current?.abort(); debouncedSearch(filters, PAGE_SIZE, (page - 1) * PAGE_SIZE); - + return () => { debouncedSearch.cancel(); }; @@ -228,6 +256,16 @@ export default function Catalogue() { t, ]); + const handleWantGoUpButtonClick = () => { + if(cataloguePageRef.current){ + cataloguePageRef.current.scrollTo({ + top: 0, + behavior: 'smooth' + }) + setWantGoUpButtonIsVisible(false) + } + } + return (
+ + {wantGoUpButtonIsVisible && ( +
+ +
+ )} +
From 87b053a283100f68a901222578a4dcd421c11a4a Mon Sep 17 00:00:00 2001 From: Kelvin Date: Fri, 10 Jan 2025 02:07:10 -0300 Subject: [PATCH 2/5] 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 aca21f651..0e142b450 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 && ( -
-
)} -
From 0f5910756b4b1577d2deb2aa76ce5d6ef8ecab3c Mon Sep 17 00:00:00 2001 From: Kelvin Date: Sat, 11 Jan 2025 14:33:57 -0300 Subject: [PATCH 3/5] feature button to go back to top and translates --- src/locales/ar/translation.json | 3 +- src/locales/be/translation.json | 3 +- src/locales/bg/translation.json | 3 +- src/locales/ca/translation.json | 3 +- src/locales/cs/translation.json | 3 +- src/locales/da/translation.json | 3 +- src/locales/de/translation.json | 3 +- src/locales/en/translation.json | 3 +- src/locales/es/translation.json | 3 +- src/locales/et/translation.json | 3 +- src/locales/fa/translation.json | 5 ++- src/locales/fr/translation.json | 3 +- src/locales/hu/translation.json | 3 +- src/locales/id/translation.json | 3 +- src/locales/it/translation.json | 3 +- src/locales/kk/translation.json | 3 +- src/locales/ko/translation.json | 3 +- src/locales/nb/translation.json | 3 +- src/locales/nl/translation.json | 3 +- src/locales/pl/translation.json | 3 +- src/locales/pt-BR/translation.json | 3 +- src/locales/pt-PT/translation.json | 3 +- src/locales/ro/translation.json | 3 +- src/locales/ru/translation.json | 3 +- src/locales/tr/translation.json | 3 +- src/locales/uk/translation.json | 3 +- src/locales/zh/translation.json | 3 +- .../src/pages/catalogue/catalogue.tsx | 43 ++++++++++--------- 28 files changed, 78 insertions(+), 48 deletions(-) diff --git a/src/locales/ar/translation.json b/src/locales/ar/translation.json index a4724b21e..50f12e068 100644 --- a/src/locales/ar/translation.json +++ b/src/locales/ar/translation.json @@ -47,7 +47,8 @@ }, "catalogue": { "next_page": "الصفحة التالية", - "previous_page": "الصفحة السابقة" + "previous_page": "الصفحة السابقة", + "go_up_buttom": "العودة إلى الأعلى" }, "game_details": { "open_download_options": "افتح خيارات التنزيل", diff --git a/src/locales/be/translation.json b/src/locales/be/translation.json index 6618e4f31..25d6549b5 100644 --- a/src/locales/be/translation.json +++ b/src/locales/be/translation.json @@ -31,7 +31,8 @@ }, "catalogue": { "next_page": "Наступная старонка", - "previous_page": "Папярэдняя старонка" + "previous_page": "Папярэдняя старонка", + "go_up_buttom": "Вярнуцца да пачатку" }, "game_details": { "open_download_options": "Адкрыць варыянты сцягвання", diff --git a/src/locales/bg/translation.json b/src/locales/bg/translation.json index 3112bb08a..241971977 100644 --- a/src/locales/bg/translation.json +++ b/src/locales/bg/translation.json @@ -47,7 +47,8 @@ }, "catalogue": { "next_page": "Следваща страница", - "previous_page": "Предишна страница" + "previous_page": "Предишна страница", + "go_up_buttom": "Обратно към върха" }, "game_details": { "open_download_options": "Варианти за изтегляне", diff --git a/src/locales/ca/translation.json b/src/locales/ca/translation.json index acf4b3c7b..d3a925e84 100644 --- a/src/locales/ca/translation.json +++ b/src/locales/ca/translation.json @@ -41,7 +41,8 @@ }, "catalogue": { "next_page": "Pàgina següent", - "previous_page": "Pàgina anterior" + "previous_page": "Pàgina anterior", + "go_up_buttom": "Torneu a la part superior" }, "game_details": { "open_download_options": "Obre les opcions de baixada", diff --git a/src/locales/cs/translation.json b/src/locales/cs/translation.json index c12914446..a4b833b90 100644 --- a/src/locales/cs/translation.json +++ b/src/locales/cs/translation.json @@ -47,7 +47,8 @@ }, "catalogue": { "next_page": "Další strana", - "previous_page": "Předchozí strana" + "previous_page": "Předchozí strana", + "go_up_buttom": "Vraťte se na vrchol" }, "game_details": { "open_download_options": "Otevřít možnosti stahování", diff --git a/src/locales/da/translation.json b/src/locales/da/translation.json index 711c81a34..63337236b 100644 --- a/src/locales/da/translation.json +++ b/src/locales/da/translation.json @@ -45,7 +45,8 @@ }, "catalogue": { "next_page": "Næste side", - "previous_page": "Forrige side" + "previous_page": "Forrige side", + "go_up_buttom": "Gå tilbage til toppen" }, "game_details": { "open_download_options": "Åben download muligheder", diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json index bf1eff601..b6bccf10c 100644 --- a/src/locales/de/translation.json +++ b/src/locales/de/translation.json @@ -41,7 +41,8 @@ }, "catalogue": { "next_page": "Nächste Seite", - "previous_page": "Vorherige Seite" + "previous_page": "Vorherige Seite", + "go_up_buttom": "Zurück nach oben gehen" }, "game_details": { "open_download_options": "Download-Optionen öffnen", diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index c93cad1a9..b35270527 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -54,7 +54,8 @@ "download_sources": "Download sources", "result_count": "{{resultCount}} results", "filter_count": "{{filterCount}} available", - "clear_filters": "Clear {{filterCount}} selected" + "clear_filters": "Clear {{filterCount}} selected", + "go_up_buttom": "Back to top" }, "game_details": { "open_download_options": "Open download options", diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json index 931ee0586..f7becf67c 100644 --- a/src/locales/es/translation.json +++ b/src/locales/es/translation.json @@ -54,7 +54,8 @@ "download_sources": "Fuentes de descarga", "result_count": "{{resultCount}} resultados", "filter_count": "{{filterCount}} disponibles", - "clear_filters": "Limpiar {{filterCount}} seleccionados" + "clear_filters": "Limpiar {{filterCount}} seleccionados", + "go_up_buttom": "Vuelve a la cima" }, "game_details": { "open_download_options": "Ver opciones de descargas", diff --git a/src/locales/et/translation.json b/src/locales/et/translation.json index 91b4a63a8..738a2a4c3 100644 --- a/src/locales/et/translation.json +++ b/src/locales/et/translation.json @@ -46,7 +46,8 @@ }, "catalogue": { "next_page": "Järgmine leht", - "previous_page": "Eelmine leht" + "previous_page": "Eelmine leht", + "go_up_buttom": "Minge tippu" }, "game_details": { "open_download_options": "Ava allalaadimise valikud", diff --git a/src/locales/fa/translation.json b/src/locales/fa/translation.json index 2409635f4..dda1c304b 100644 --- a/src/locales/fa/translation.json +++ b/src/locales/fa/translation.json @@ -31,7 +31,8 @@ }, "catalogue": { "next_page": "صفحه‌ی بعدی", - "previous_page": "صفحه‌ی قبلی" + "previous_page": "صفحه‌ی قبلی", + "go_up_buttom": "به بالا برگردید" }, "game_details": { "open_download_options": "بازکردن آپشن‌های دانلود", @@ -135,4 +136,4 @@ "modal": { "close": "دکمه‌ی خروج" } -} +} \ No newline at end of file diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json index 4d310681d..17c706f82 100644 --- a/src/locales/fr/translation.json +++ b/src/locales/fr/translation.json @@ -120,6 +120,7 @@ }, "catalogue": { "next_page": "Page suivante", - "previous_page": "Page précédente" + "previous_page": "Page précédente", + "go_up_buttom": "Retourner au sommet" } } diff --git a/src/locales/hu/translation.json b/src/locales/hu/translation.json index 0863d1e87..8d03c88db 100644 --- a/src/locales/hu/translation.json +++ b/src/locales/hu/translation.json @@ -31,7 +31,8 @@ }, "catalogue": { "next_page": "Következő olda", - "previous_page": "Előző olda" + "previous_page": "Előző olda", + "go_up_buttom": "Menj vissza a tetejére" }, "game_details": { "open_download_options": "Letöltési lehetőségek", diff --git a/src/locales/id/translation.json b/src/locales/id/translation.json index ba4a06f19..57159600a 100644 --- a/src/locales/id/translation.json +++ b/src/locales/id/translation.json @@ -41,7 +41,8 @@ }, "catalogue": { "next_page": "Halaman Berikutnya", - "previous_page": "Halaman Sebelumnya" + "previous_page": "Halaman Sebelumnya", + "go_up_buttom": "Kembali ke atas" }, "game_details": { "open_download_options": "Buka opsi unduhan", diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json index cf763320f..ee3cbc570 100644 --- a/src/locales/it/translation.json +++ b/src/locales/it/translation.json @@ -31,7 +31,8 @@ }, "catalogue": { "next_page": "Pagina successiva", - "previous_page": "Pagina precedente" + "previous_page": "Pagina precedente", + "go_up_buttom": "Torna in cima" }, "game_details": { "open_download_options": "Apri opzioni di download", diff --git a/src/locales/kk/translation.json b/src/locales/kk/translation.json index 6d5d84044..3fd1751c3 100644 --- a/src/locales/kk/translation.json +++ b/src/locales/kk/translation.json @@ -40,7 +40,8 @@ }, "catalogue": { "next_page": "Келесі бет", - "previous_page": "Алдыңғы бет" + "previous_page": "Алдыңғы бет", + "go_up_buttom": "Жоғарыға оралу" }, "game_details": { "open_download_options": "Жүктеу нұсқаларын ашу", diff --git a/src/locales/ko/translation.json b/src/locales/ko/translation.json index 2656bb452..7eb791153 100644 --- a/src/locales/ko/translation.json +++ b/src/locales/ko/translation.json @@ -31,7 +31,8 @@ }, "catalogue": { "next_page": "다음 페이지", - "previous_page": "이전 페이지" + "previous_page": "이전 페이지", + "go_up_buttom": "상단으로 돌아갑니다" }, "game_details": { "open_download_options": "다운로드 선택지 열기", diff --git a/src/locales/nb/translation.json b/src/locales/nb/translation.json index 5c5f68823..f97c3225b 100644 --- a/src/locales/nb/translation.json +++ b/src/locales/nb/translation.json @@ -45,7 +45,8 @@ }, "catalogue": { "next_page": "Neste side", - "previous_page": "Forrige side" + "previous_page": "Forrige side", + "go_up_buttom": "Gå tilbake til toppen" }, "game_details": { "open_download_options": "Åpne nedlastingsmuligheter", diff --git a/src/locales/nl/translation.json b/src/locales/nl/translation.json index bb7abf59c..e12034d09 100644 --- a/src/locales/nl/translation.json +++ b/src/locales/nl/translation.json @@ -31,7 +31,8 @@ }, "catalogue": { "next_page": "Volgende Pagina", - "previous_page": "Vorige Pagina" + "previous_page": "Vorige Pagina", + "go_up_buttom": "Ga terug naar de top" }, "game_details": { "open_download_options": "Open download Instellingen", diff --git a/src/locales/pl/translation.json b/src/locales/pl/translation.json index 945c857a0..38c70160d 100644 --- a/src/locales/pl/translation.json +++ b/src/locales/pl/translation.json @@ -31,7 +31,8 @@ }, "catalogue": { "next_page": "Następna strona", - "previous_page": "Poprzednia strona" + "previous_page": "Poprzednia strona", + "go_up_buttom": "Wróć na szczyt" }, "game_details": { "open_download_options": "Otwórz opcje pobierania", diff --git a/src/locales/pt-BR/translation.json b/src/locales/pt-BR/translation.json index 1c8801765..a4a602a69 100644 --- a/src/locales/pt-BR/translation.json +++ b/src/locales/pt-BR/translation.json @@ -295,7 +295,8 @@ "download_sources": "Fontes de download", "result_count": "{{resultCount}} resultados", "filter_count": "{{filterCount}} disponíveis", - "clear_filters": "Limpar {{filterCount}} selecionados" + "clear_filters": "Limpar {{filterCount}} selecionados", + "go_up_buttom": "Voltar ao topo" }, "modal": { "close": "Botão de fechar" diff --git a/src/locales/pt-PT/translation.json b/src/locales/pt-PT/translation.json index ce081b3f6..92cc1e464 100644 --- a/src/locales/pt-PT/translation.json +++ b/src/locales/pt-PT/translation.json @@ -273,7 +273,8 @@ }, "catalogue": { "next_page": "Página seguinte", - "previous_page": "Página anterior" + "previous_page": "Página anterior", + "go_up_buttom": "Voltar ao topo" }, "modal": { "close": "Botão de fechar" diff --git a/src/locales/ro/translation.json b/src/locales/ro/translation.json index 69d140719..7ebca0af8 100644 --- a/src/locales/ro/translation.json +++ b/src/locales/ro/translation.json @@ -32,7 +32,8 @@ }, "catalogue": { "next_page": "Pagina următoare", - "previous_page": "Pagina anterioară" + "previous_page": "Pagina anterioară", + "go_up_buttom": "Înapoi în vârf" }, "game_details": { "open_download_options": "Deschide opțiunile de descărcare", diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json index 741f5e16f..677b2b8da 100644 --- a/src/locales/ru/translation.json +++ b/src/locales/ru/translation.json @@ -54,7 +54,8 @@ "download_sources": "Источники загрузки", "result_count": "{{resultCount}} результатов", "filter_count": "{{filterCount}} доступных", - "clear_filters": "Очистить {{filterCount}} выбранных" + "clear_filters": "Очистить {{filterCount}} выбранных", + "go_up_buttom": "Вернуться на вершину" }, "game_details": { "open_download_options": "Открыть источники", diff --git a/src/locales/tr/translation.json b/src/locales/tr/translation.json index 6757fdf51..d35ce02d9 100644 --- a/src/locales/tr/translation.json +++ b/src/locales/tr/translation.json @@ -31,7 +31,8 @@ }, "catalogue": { "next_page": "Sonraki sayfa", - "previous_page": "Önceki sayfa" + "previous_page": "Önceki sayfa", + "go_up_buttom": "Tepeye dön" }, "game_details": { "open_download_options": "İndirme seçeneklerini aç", diff --git a/src/locales/uk/translation.json b/src/locales/uk/translation.json index ed4b3d588..25be7f19d 100644 --- a/src/locales/uk/translation.json +++ b/src/locales/uk/translation.json @@ -40,7 +40,8 @@ }, "catalogue": { "next_page": "Наступна сторінка", - "previous_page": "Попередня сторінка" + "previous_page": "Попередня сторінка", + "go_up_buttom": "Назад до вершини" }, "game_details": { "open_download_options": "Відкрити варіанти завантаження", diff --git a/src/locales/zh/translation.json b/src/locales/zh/translation.json index 664877fa8..d6b8300da 100644 --- a/src/locales/zh/translation.json +++ b/src/locales/zh/translation.json @@ -46,7 +46,8 @@ }, "catalogue": { "next_page": "下一页", - "previous_page": "上一页" + "previous_page": "上一页", + "go_up_buttom": "回到顶部" }, "game_details": { "open_download_options": "打开下载菜单", diff --git a/src/renderer/src/pages/catalogue/catalogue.tsx b/src/renderer/src/pages/catalogue/catalogue.tsx index 0e142b450..7a8cef48e 100644 --- a/src/renderer/src/pages/catalogue/catalogue.tsx +++ b/src/renderer/src/pages/catalogue/catalogue.tsx @@ -32,9 +32,11 @@ const filterCategoryColors = { publishers: "hsl(200deg 50% 30%)", }; + + const PAGE_SIZE = 20; const TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM = 10; -// const LIMIT_SCROLL_TO_DISAPEAR_GO_UP_BUTTOM = 225; +const LIMIT_SCROLL_TO_DISAPEAR_GO_UP_BUTTOM = 500; export default function Catalogue() { const abortControllerRef = useRef(null); @@ -84,29 +86,33 @@ export default function Catalogue() { }, 500) ).current; + const isGoUpButtonVisible = (results: any[], scrollTop: number) => { + const withinLimit = results.length > 0 && results.length <= TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM; + return withinLimit && scrollTop >= LIMIT_SCROLL_TO_DISAPEAR_GO_UP_BUTTOM; + }; + useEffect(() => { - results.length > 0 && results.length <= TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM - ? setWantGoUpButtonIsVisible(true) - : setWantGoUpButtonIsVisible(false); - console.log(cataloguePageRef.current?.scrollTop); - }, [results]); + const withinLimit = results.length > 0 && results.length <= TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM; + setWantGoUpButtonIsVisible(withinLimit); + }, [results]) useEffect(() => { - const handleScroll = () => { + const handleScroll = debounce(() => { if (cataloguePageRef.current) { - console.log(cataloguePageRef.current.scrollTop); - // setScrollPosition(cataloguePageRef.current.scrollTop); + const scrollTop = cataloguePageRef.current.scrollTop + setWantGoUpButtonIsVisible(isGoUpButtonVisible(results, scrollTop)) } - }; - - if (cataloguePageRef.current) { - cataloguePageRef.current.addEventListener("scroll", handleScroll); + }, 100) + + const ref = cataloguePageRef.current + if (ref) { + ref.addEventListener("scroll", handleScroll); } return () => { - cataloguePageRef.current?.removeEventListener("scroll", handleScroll); + ref?.removeEventListener("scroll", handleScroll); }; - }, []); + }, [results]); useEffect(() => { setResults([]); @@ -264,7 +270,6 @@ export default function Catalogue() { top: 0, behavior: "smooth", }); - setWantGoUpButtonIsVisible(false); } }; @@ -372,14 +377,12 @@ export default function Catalogue() {
{wantGoUpButtonIsVisible && ( -
- -
)} From ca7bc62285876a1db3310c9944a71aecc2ef7629 Mon Sep 17 00:00:00 2001 From: Kelvin Date: Sat, 11 Jan 2025 14:59:49 -0300 Subject: [PATCH 4/5] Fixed typing errors and cleanup of debounce in useEffect --- src/locales/ar/translation.json | 2 +- src/locales/be/translation.json | 2 +- src/locales/bg/translation.json | 2 +- src/locales/ca/translation.json | 2 +- src/locales/cs/translation.json | 2 +- src/locales/da/translation.json | 2 +- src/locales/de/translation.json | 2 +- src/locales/en/translation.json | 2 +- src/locales/es/translation.json | 2 +- src/locales/et/translation.json | 2 +- src/locales/fa/translation.json | 2 +- src/locales/fr/translation.json | 2 +- src/locales/hu/translation.json | 2 +- src/locales/id/translation.json | 2 +- src/locales/it/translation.json | 2 +- src/locales/kk/translation.json | 2 +- src/locales/ko/translation.json | 2 +- src/locales/nb/translation.json | 2 +- src/locales/nl/translation.json | 2 +- src/locales/pl/translation.json | 2 +- src/locales/pt-BR/translation.json | 2 +- src/locales/pt-PT/translation.json | 2 +- src/locales/ro/translation.json | 2 +- src/locales/ru/translation.json | 2 +- src/locales/tr/translation.json | 2 +- src/locales/uk/translation.json | 2 +- src/locales/zh/translation.json | 2 +- src/renderer/src/pages/catalogue/catalogue.tsx | 7 ++++--- 28 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/locales/ar/translation.json b/src/locales/ar/translation.json index 50f12e068..3df755983 100644 --- a/src/locales/ar/translation.json +++ b/src/locales/ar/translation.json @@ -48,7 +48,7 @@ "catalogue": { "next_page": "الصفحة التالية", "previous_page": "الصفحة السابقة", - "go_up_buttom": "العودة إلى الأعلى" + "go_up_button": "العودة إلى الأعلى" }, "game_details": { "open_download_options": "افتح خيارات التنزيل", diff --git a/src/locales/be/translation.json b/src/locales/be/translation.json index 25d6549b5..b78f7d6df 100644 --- a/src/locales/be/translation.json +++ b/src/locales/be/translation.json @@ -32,7 +32,7 @@ "catalogue": { "next_page": "Наступная старонка", "previous_page": "Папярэдняя старонка", - "go_up_buttom": "Вярнуцца да пачатку" + "go_up_button": "Вярнуцца да пачатку" }, "game_details": { "open_download_options": "Адкрыць варыянты сцягвання", diff --git a/src/locales/bg/translation.json b/src/locales/bg/translation.json index 241971977..e52ea2354 100644 --- a/src/locales/bg/translation.json +++ b/src/locales/bg/translation.json @@ -48,7 +48,7 @@ "catalogue": { "next_page": "Следваща страница", "previous_page": "Предишна страница", - "go_up_buttom": "Обратно към върха" + "go_up_button": "Обратно към върха" }, "game_details": { "open_download_options": "Варианти за изтегляне", diff --git a/src/locales/ca/translation.json b/src/locales/ca/translation.json index d3a925e84..8f9b8a9cb 100644 --- a/src/locales/ca/translation.json +++ b/src/locales/ca/translation.json @@ -42,7 +42,7 @@ "catalogue": { "next_page": "Pàgina següent", "previous_page": "Pàgina anterior", - "go_up_buttom": "Torneu a la part superior" + "go_up_button": "Torneu a la part superior" }, "game_details": { "open_download_options": "Obre les opcions de baixada", diff --git a/src/locales/cs/translation.json b/src/locales/cs/translation.json index a4b833b90..fe3ea9053 100644 --- a/src/locales/cs/translation.json +++ b/src/locales/cs/translation.json @@ -48,7 +48,7 @@ "catalogue": { "next_page": "Další strana", "previous_page": "Předchozí strana", - "go_up_buttom": "Vraťte se na vrchol" + "go_up_button": "Vraťte se na vrchol" }, "game_details": { "open_download_options": "Otevřít možnosti stahování", diff --git a/src/locales/da/translation.json b/src/locales/da/translation.json index 63337236b..234f396a5 100644 --- a/src/locales/da/translation.json +++ b/src/locales/da/translation.json @@ -46,7 +46,7 @@ "catalogue": { "next_page": "Næste side", "previous_page": "Forrige side", - "go_up_buttom": "Gå tilbage til toppen" + "go_up_button": "Gå tilbage til toppen" }, "game_details": { "open_download_options": "Åben download muligheder", diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json index b6bccf10c..a58f79704 100644 --- a/src/locales/de/translation.json +++ b/src/locales/de/translation.json @@ -42,7 +42,7 @@ "catalogue": { "next_page": "Nächste Seite", "previous_page": "Vorherige Seite", - "go_up_buttom": "Zurück nach oben gehen" + "go_up_button": "Zurück nach oben gehen" }, "game_details": { "open_download_options": "Download-Optionen öffnen", diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index b35270527..45447d61d 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -55,7 +55,7 @@ "result_count": "{{resultCount}} results", "filter_count": "{{filterCount}} available", "clear_filters": "Clear {{filterCount}} selected", - "go_up_buttom": "Back to top" + "go_up_button": "Back to top" }, "game_details": { "open_download_options": "Open download options", diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json index f7becf67c..2a2161870 100644 --- a/src/locales/es/translation.json +++ b/src/locales/es/translation.json @@ -55,7 +55,7 @@ "result_count": "{{resultCount}} resultados", "filter_count": "{{filterCount}} disponibles", "clear_filters": "Limpiar {{filterCount}} seleccionados", - "go_up_buttom": "Vuelve a la cima" + "go_up_button": "Vuelve a la cima" }, "game_details": { "open_download_options": "Ver opciones de descargas", diff --git a/src/locales/et/translation.json b/src/locales/et/translation.json index 738a2a4c3..74a1c9068 100644 --- a/src/locales/et/translation.json +++ b/src/locales/et/translation.json @@ -47,7 +47,7 @@ "catalogue": { "next_page": "Järgmine leht", "previous_page": "Eelmine leht", - "go_up_buttom": "Minge tippu" + "go_up_button": "Minge tippu" }, "game_details": { "open_download_options": "Ava allalaadimise valikud", diff --git a/src/locales/fa/translation.json b/src/locales/fa/translation.json index dda1c304b..200c92bfb 100644 --- a/src/locales/fa/translation.json +++ b/src/locales/fa/translation.json @@ -32,7 +32,7 @@ "catalogue": { "next_page": "صفحه‌ی بعدی", "previous_page": "صفحه‌ی قبلی", - "go_up_buttom": "به بالا برگردید" + "go_up_button": "به بالا برگردید" }, "game_details": { "open_download_options": "بازکردن آپشن‌های دانلود", diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json index 17c706f82..6fdcf2c0a 100644 --- a/src/locales/fr/translation.json +++ b/src/locales/fr/translation.json @@ -121,6 +121,6 @@ "catalogue": { "next_page": "Page suivante", "previous_page": "Page précédente", - "go_up_buttom": "Retourner au sommet" + "go_up_button": "Retourner au sommet" } } diff --git a/src/locales/hu/translation.json b/src/locales/hu/translation.json index 8d03c88db..37bd41fca 100644 --- a/src/locales/hu/translation.json +++ b/src/locales/hu/translation.json @@ -32,7 +32,7 @@ "catalogue": { "next_page": "Következő olda", "previous_page": "Előző olda", - "go_up_buttom": "Menj vissza a tetejére" + "go_up_button": "Menj vissza a tetejére" }, "game_details": { "open_download_options": "Letöltési lehetőségek", diff --git a/src/locales/id/translation.json b/src/locales/id/translation.json index 57159600a..1705839cc 100644 --- a/src/locales/id/translation.json +++ b/src/locales/id/translation.json @@ -42,7 +42,7 @@ "catalogue": { "next_page": "Halaman Berikutnya", "previous_page": "Halaman Sebelumnya", - "go_up_buttom": "Kembali ke atas" + "go_up_button": "Kembali ke atas" }, "game_details": { "open_download_options": "Buka opsi unduhan", diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json index ee3cbc570..ab5570fc1 100644 --- a/src/locales/it/translation.json +++ b/src/locales/it/translation.json @@ -32,7 +32,7 @@ "catalogue": { "next_page": "Pagina successiva", "previous_page": "Pagina precedente", - "go_up_buttom": "Torna in cima" + "go_up_button": "Torna in cima" }, "game_details": { "open_download_options": "Apri opzioni di download", diff --git a/src/locales/kk/translation.json b/src/locales/kk/translation.json index 3fd1751c3..85eca2ca8 100644 --- a/src/locales/kk/translation.json +++ b/src/locales/kk/translation.json @@ -41,7 +41,7 @@ "catalogue": { "next_page": "Келесі бет", "previous_page": "Алдыңғы бет", - "go_up_buttom": "Жоғарыға оралу" + "go_up_button": "Жоғарыға оралу" }, "game_details": { "open_download_options": "Жүктеу нұсқаларын ашу", diff --git a/src/locales/ko/translation.json b/src/locales/ko/translation.json index 7eb791153..567bf6ac4 100644 --- a/src/locales/ko/translation.json +++ b/src/locales/ko/translation.json @@ -32,7 +32,7 @@ "catalogue": { "next_page": "다음 페이지", "previous_page": "이전 페이지", - "go_up_buttom": "상단으로 돌아갑니다" + "go_up_button": "상단으로 돌아갑니다" }, "game_details": { "open_download_options": "다운로드 선택지 열기", diff --git a/src/locales/nb/translation.json b/src/locales/nb/translation.json index f97c3225b..053bc12fb 100644 --- a/src/locales/nb/translation.json +++ b/src/locales/nb/translation.json @@ -46,7 +46,7 @@ "catalogue": { "next_page": "Neste side", "previous_page": "Forrige side", - "go_up_buttom": "Gå tilbake til toppen" + "go_up_button": "Gå tilbake til toppen" }, "game_details": { "open_download_options": "Åpne nedlastingsmuligheter", diff --git a/src/locales/nl/translation.json b/src/locales/nl/translation.json index e12034d09..9fbc9fe23 100644 --- a/src/locales/nl/translation.json +++ b/src/locales/nl/translation.json @@ -32,7 +32,7 @@ "catalogue": { "next_page": "Volgende Pagina", "previous_page": "Vorige Pagina", - "go_up_buttom": "Ga terug naar de top" + "go_up_button": "Ga terug naar de top" }, "game_details": { "open_download_options": "Open download Instellingen", diff --git a/src/locales/pl/translation.json b/src/locales/pl/translation.json index 38c70160d..12f31b0d5 100644 --- a/src/locales/pl/translation.json +++ b/src/locales/pl/translation.json @@ -32,7 +32,7 @@ "catalogue": { "next_page": "Następna strona", "previous_page": "Poprzednia strona", - "go_up_buttom": "Wróć na szczyt" + "go_up_button": "Wróć na szczyt" }, "game_details": { "open_download_options": "Otwórz opcje pobierania", diff --git a/src/locales/pt-BR/translation.json b/src/locales/pt-BR/translation.json index a4a602a69..9cbbbc318 100644 --- a/src/locales/pt-BR/translation.json +++ b/src/locales/pt-BR/translation.json @@ -296,7 +296,7 @@ "result_count": "{{resultCount}} resultados", "filter_count": "{{filterCount}} disponíveis", "clear_filters": "Limpar {{filterCount}} selecionados", - "go_up_buttom": "Voltar ao topo" + "go_up_button": "Voltar ao topo" }, "modal": { "close": "Botão de fechar" diff --git a/src/locales/pt-PT/translation.json b/src/locales/pt-PT/translation.json index 92cc1e464..6dd806deb 100644 --- a/src/locales/pt-PT/translation.json +++ b/src/locales/pt-PT/translation.json @@ -274,7 +274,7 @@ "catalogue": { "next_page": "Página seguinte", "previous_page": "Página anterior", - "go_up_buttom": "Voltar ao topo" + "go_up_button": "Voltar ao topo" }, "modal": { "close": "Botão de fechar" diff --git a/src/locales/ro/translation.json b/src/locales/ro/translation.json index 7ebca0af8..e653234c2 100644 --- a/src/locales/ro/translation.json +++ b/src/locales/ro/translation.json @@ -33,7 +33,7 @@ "catalogue": { "next_page": "Pagina următoare", "previous_page": "Pagina anterioară", - "go_up_buttom": "Înapoi în vârf" + "go_up_button": "Înapoi în vârf" }, "game_details": { "open_download_options": "Deschide opțiunile de descărcare", diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json index 677b2b8da..3cf9993ce 100644 --- a/src/locales/ru/translation.json +++ b/src/locales/ru/translation.json @@ -55,7 +55,7 @@ "result_count": "{{resultCount}} результатов", "filter_count": "{{filterCount}} доступных", "clear_filters": "Очистить {{filterCount}} выбранных", - "go_up_buttom": "Вернуться на вершину" + "go_up_button": "Вернуться на вершину" }, "game_details": { "open_download_options": "Открыть источники", diff --git a/src/locales/tr/translation.json b/src/locales/tr/translation.json index d35ce02d9..f8d5818d1 100644 --- a/src/locales/tr/translation.json +++ b/src/locales/tr/translation.json @@ -32,7 +32,7 @@ "catalogue": { "next_page": "Sonraki sayfa", "previous_page": "Önceki sayfa", - "go_up_buttom": "Tepeye dön" + "go_up_button": "Tepeye dön" }, "game_details": { "open_download_options": "İndirme seçeneklerini aç", diff --git a/src/locales/uk/translation.json b/src/locales/uk/translation.json index 25be7f19d..197eb49dc 100644 --- a/src/locales/uk/translation.json +++ b/src/locales/uk/translation.json @@ -41,7 +41,7 @@ "catalogue": { "next_page": "Наступна сторінка", "previous_page": "Попередня сторінка", - "go_up_buttom": "Назад до вершини" + "go_up_button": "Назад до вершини" }, "game_details": { "open_download_options": "Відкрити варіанти завантаження", diff --git a/src/locales/zh/translation.json b/src/locales/zh/translation.json index d6b8300da..825359d4a 100644 --- a/src/locales/zh/translation.json +++ b/src/locales/zh/translation.json @@ -47,7 +47,7 @@ "catalogue": { "next_page": "下一页", "previous_page": "上一页", - "go_up_buttom": "回到顶部" + "go_up_button": "回到顶部" }, "game_details": { "open_download_options": "打开下载菜单", diff --git a/src/renderer/src/pages/catalogue/catalogue.tsx b/src/renderer/src/pages/catalogue/catalogue.tsx index 7a8cef48e..42afeb116 100644 --- a/src/renderer/src/pages/catalogue/catalogue.tsx +++ b/src/renderer/src/pages/catalogue/catalogue.tsx @@ -36,7 +36,7 @@ const filterCategoryColors = { const PAGE_SIZE = 20; const TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM = 10; -const LIMIT_SCROLL_TO_DISAPEAR_GO_UP_BUTTOM = 500; +const LIMIT_SCROLL_TO_DISAPEAR_GO_UP_BUTTON = 500; export default function Catalogue() { const abortControllerRef = useRef(null); @@ -88,7 +88,7 @@ export default function Catalogue() { const isGoUpButtonVisible = (results: any[], scrollTop: number) => { const withinLimit = results.length > 0 && results.length <= TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM; - return withinLimit && scrollTop >= LIMIT_SCROLL_TO_DISAPEAR_GO_UP_BUTTOM; + return withinLimit && scrollTop >= LIMIT_SCROLL_TO_DISAPEAR_GO_UP_BUTTON; }; useEffect(() => { @@ -111,6 +111,7 @@ export default function Catalogue() { return () => { ref?.removeEventListener("scroll", handleScroll); + handleScroll.cancel(); }; }, [results]); @@ -381,7 +382,7 @@ export default function Catalogue() { {t("result_count", { resultCount: formatNumber(itemsCount), })} - , {t('go_up_buttom')} + , {t('go_up_button')} )} From 74c28705372a73c3f97f77c5a81474467d3e7a50 Mon Sep 17 00:00:00 2001 From: Kelvin Date: Sat, 11 Jan 2025 15:29:07 -0300 Subject: [PATCH 5/5] running format --- src/locales/fa/translation.json | 2 +- src/main/services/hosters/datanodes.ts | 3 +- .../src/pages/catalogue/catalogue.tsx | 36 ++++++++++--------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/locales/fa/translation.json b/src/locales/fa/translation.json index 200c92bfb..8b4239d19 100644 --- a/src/locales/fa/translation.json +++ b/src/locales/fa/translation.json @@ -136,4 +136,4 @@ "modal": { "close": "دکمه‌ی خروج" } -} \ No newline at end of file +} diff --git a/src/main/services/hosters/datanodes.ts b/src/main/services/hosters/datanodes.ts index d77e7d514..ae1444180 100644 --- a/src/main/services/hosters/datanodes.ts +++ b/src/main/services/hosters/datanodes.ts @@ -33,7 +33,8 @@ export class DatanodesApi { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36", }, - maxRedirects: 0, validateStatus: (status: number) => status === 302 || status < 400, + maxRedirects: 0, + validateStatus: (status: number) => status === 302 || status < 400, } ); diff --git a/src/renderer/src/pages/catalogue/catalogue.tsx b/src/renderer/src/pages/catalogue/catalogue.tsx index 42afeb116..652aaea58 100644 --- a/src/renderer/src/pages/catalogue/catalogue.tsx +++ b/src/renderer/src/pages/catalogue/catalogue.tsx @@ -32,8 +32,6 @@ const filterCategoryColors = { publishers: "hsl(200deg 50% 30%)", }; - - const PAGE_SIZE = 20; const TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM = 10; const LIMIT_SCROLL_TO_DISAPEAR_GO_UP_BUTTON = 500; @@ -87,24 +85,26 @@ export default function Catalogue() { ).current; const isGoUpButtonVisible = (results: any[], scrollTop: number) => { - const withinLimit = results.length > 0 && results.length <= TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM; + const withinLimit = + results.length > 0 && results.length <= TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM; return withinLimit && scrollTop >= LIMIT_SCROLL_TO_DISAPEAR_GO_UP_BUTTON; }; useEffect(() => { - const withinLimit = results.length > 0 && results.length <= TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM; + const withinLimit = + results.length > 0 && results.length <= TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM; setWantGoUpButtonIsVisible(withinLimit); - }, [results]) + }, [results]); useEffect(() => { const handleScroll = debounce(() => { if (cataloguePageRef.current) { - const scrollTop = cataloguePageRef.current.scrollTop - setWantGoUpButtonIsVisible(isGoUpButtonVisible(results, scrollTop)) + const scrollTop = cataloguePageRef.current.scrollTop; + setWantGoUpButtonIsVisible(isGoUpButtonVisible(results, scrollTop)); } - }, 100) - - const ref = cataloguePageRef.current + }, 100); + + const ref = cataloguePageRef.current; if (ref) { ref.addEventListener("scroll", handleScroll); } @@ -378,12 +378,16 @@ export default function Catalogue() { {wantGoUpButtonIsVisible && ( - + )}