mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-06-27 09:31:21 +00:00
Merge pull request #95 from Qortal/bugfix/timeouts-minting
fix interval settimeout for minting
This commit is contained in:
commit
bdd08b76a1
@ -26,6 +26,7 @@ import {
|
|||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
useMemo,
|
useMemo,
|
||||||
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import CloseIcon from '@mui/icons-material/Close';
|
import CloseIcon from '@mui/icons-material/Close';
|
||||||
@ -92,7 +93,12 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
|||||||
const [names, setNames] = useState({});
|
const [names, setNames] = useState({});
|
||||||
const [accountInfos, setAccountInfos] = useState({});
|
const [accountInfos, setAccountInfos] = useState({});
|
||||||
const [showWaitDialog, setShowWaitDialog] = useState(false);
|
const [showWaitDialog, setShowWaitDialog] = useState(false);
|
||||||
|
const timeoutNodeStatusRef = useRef<ReturnType<typeof setTimeout> | null>(
|
||||||
|
null
|
||||||
|
);
|
||||||
|
const timeoutAdminInfoRef = useRef<ReturnType<typeof setTimeout> | null>(
|
||||||
|
null
|
||||||
|
);
|
||||||
const isPartOfMintingGroup = useMemo(() => {
|
const isPartOfMintingGroup = useMemo(() => {
|
||||||
if (groups?.length === 0) return false;
|
if (groups?.length === 0) return false;
|
||||||
return !!groups?.find((item) => item?.groupId?.toString() === '694');
|
return !!groups?.find((item) => item?.groupId?.toString() === '694');
|
||||||
@ -214,9 +220,10 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
|||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
setAdminInfo(data);
|
setAdminInfo(data);
|
||||||
setTimeout(getAdminInfo, 30000);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
} finally {
|
||||||
|
timeoutAdminInfoRef.current = setTimeout(getAccountInfo, 30000);
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -226,9 +233,10 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
|||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
setNodeStatus(data);
|
setNodeStatus(data);
|
||||||
setTimeout(getNodeStatus, 30000);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Request failed', error);
|
console.error('Request failed', error);
|
||||||
|
} finally {
|
||||||
|
timeoutNodeStatusRef.current = setTimeout(getNodeStatus, 30000);
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -531,6 +539,17 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
|||||||
getAdminInfo();
|
getAdminInfo();
|
||||||
getMintingAccounts();
|
getMintingAccounts();
|
||||||
getNodeStatus();
|
getNodeStatus();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (timeoutNodeStatusRef.current) {
|
||||||
|
clearTimeout(timeoutNodeStatusRef.current);
|
||||||
|
timeoutNodeStatusRef.current = null;
|
||||||
|
}
|
||||||
|
if (timeoutAdminInfoRef.current) {
|
||||||
|
clearTimeout(timeoutAdminInfoRef.current);
|
||||||
|
timeoutAdminInfoRef.current = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user