AuthorizeRejectButtons: skip animations if countdown is undefined

This commit is contained in:
Alex Gleason 2023-03-27 17:08:24 -05:00
parent 09ed0bccab
commit f216b52b36
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -26,15 +26,20 @@ const AuthorizeRejectButtons: React.FC<IAuthorizeRejectButtons> = ({ onAuthorize
}
setState('pending');
} else {
setState(present);
timeout.current = setTimeout(async () => {
const doAction = async () => {
try {
await action();
setState(past);
} catch (e) {
console.error(e);
}
}, countdown);
};
if (typeof countdown === 'number') {
setState(present);
timeout.current = setTimeout(doAction, countdown);
} else {
doAction();
}
}
}