Skip to content

Commit

Permalink
disable refresh btn
Browse files Browse the repository at this point in the history
  • Loading branch information
Megha-Dev-19 committed Jan 28, 2025
1 parent 961a759 commit 7eb5408
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const [lockupNearWithdrawTokens, setLockupNearWithdrawTokens] = useState(null);
const [nearPrice, setNearPrice] = useState(null);
const [userFTTokens, setFTTokens] = useState(null);
const [show404Modal, setShow404Modal] = useState(false);
const [disableRefreshBtn, setDisableRefreshBtn] = useState(false);

useEffect(() => {
asyncFetch(`${REPL_BACKEND_API}/near-price`)
Expand Down Expand Up @@ -110,6 +111,27 @@ useEffect(() => {
});
}, []);

// disable refresh btn for 30 seconds
useEffect(() => {
if (show404Modal) {
setDisableRefreshBtn(true);
}
}, [show404Modal]);

useEffect(() => {
let timer;

if (disableRefreshBtn) {
timer = setTimeout(() => {
setDisableRefreshBtn(false);
}, 30_000);
}

return () => {
clearTimeout(timer);
};
}, [disableRefreshBtn]);

function formatNearAmount(amount) {
return Big(amount ?? "0")
.div(Big(10).pow(24))
Expand Down Expand Up @@ -217,6 +239,7 @@ const TooManyRequestModal = () => {
props={{
classNames: { root: "theme-btn" },
label: "Refresh",
disabled: disableRefreshBtn,
}}
/>
</a>
Expand Down

0 comments on commit 7eb5408

Please sign in to comment.