refactor: simplify donation modal logic (#58280)

This commit is contained in:
Oliver Eyton-Williams
2025-01-24 00:03:03 +01:00
committed by GitHub
parent 9429f52fd4
commit 4eef3854c7

View File

@@ -254,25 +254,16 @@ function DonationModalBody({
};
useEffect(() => {
const interval = setInterval(() => {
setSecondsRemaining(prevSeconds => {
if (prevSeconds > 0) {
return prevSeconds - 1;
} else {
setIsAnimationVisible(false);
clearInterval(interval);
return 0;
}
});
const intervalId = setInterval(() => {
setSecondsRemaining(prevSeconds => prevSeconds - 1);
}, 1000);
return () => clearInterval(interval);
}, []);
useEffect(() => {
if (secondsRemaining === 0) {
if (secondsRemaining <= 0) {
setIsAnimationVisible(false);
setCanClose(true);
clearInterval(intervalId);
}
return () => clearInterval(intervalId);
}, [secondsRemaining, setCanClose]);
return (