Skip to content

Commit

Permalink
running format
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinDiasMoreira committed Jan 11, 2025
1 parent 751ade8 commit 74c2870
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/locales/fa/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@
"modal": {
"close": "دکمه‌ی خروج"
}
}
}
3 changes: 2 additions & 1 deletion src/main/services/hosters/datanodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
);

Expand Down
36 changes: 20 additions & 16 deletions src/renderer/src/pages/catalogue/catalogue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -378,12 +378,16 @@ export default function Catalogue() {
</div>

{wantGoUpButtonIsVisible && (
<Button onClick={handleWantGoUpButtonClick} theme="outline" style={{ position: "fixed", bottom: 16, left: 16 }}>
{t("result_count", {
resultCount: formatNumber(itemsCount),
})}
, {t('go_up_button')} <ArrowUpIcon />
</Button>
<Button
onClick={handleWantGoUpButtonClick}
theme="outline"
style={{ position: "fixed", bottom: 16, left: 16 }}
>
{t("result_count", {
resultCount: formatNumber(itemsCount),
})}
, {t("go_up_button")} <ArrowUpIcon />
</Button>
)}
</div>

Expand Down

0 comments on commit 74c2870

Please sign in to comment.