Fix: Only start polling the server on success response
MAILPOET-4300
This commit is contained in:
committed by
Veljko V
parent
ef5e45ba32
commit
1b103c653f
@ -122,6 +122,8 @@ function AuthorizeSenderEmailModal({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearCurrentInterval(setIntervalId.current);
|
||||||
|
|
||||||
makeApiRequest(senderEmailAddress)
|
makeApiRequest(senderEmailAddress)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const response = Boolean(res?.data);
|
const response = Boolean(res?.data);
|
||||||
@ -130,6 +132,16 @@ function AuthorizeSenderEmailModal({
|
|||||||
if (response) {
|
if (response) {
|
||||||
// if pending or already authorized perform the check ahead
|
// if pending or already authorized perform the check ahead
|
||||||
executeAction();
|
executeAction();
|
||||||
|
|
||||||
|
// start polling on success response
|
||||||
|
setIntervalStopTime.current = moment()
|
||||||
|
.add(STOP_POLLING_AFTER, 'hours')
|
||||||
|
.valueOf();
|
||||||
|
|
||||||
|
setIntervalId.current = setInterval(
|
||||||
|
executeAction,
|
||||||
|
1000 * SET_INTERVAL_SECONDS,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@ -137,15 +149,7 @@ function AuthorizeSenderEmailModal({
|
|||||||
setShowLoader(false);
|
setShowLoader(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
clearCurrentInterval(setIntervalId.current);
|
return () => clearCurrentInterval(setIntervalId.current);
|
||||||
setIntervalStopTime.current = moment()
|
|
||||||
.add(STOP_POLLING_AFTER, 'hours')
|
|
||||||
.valueOf();
|
|
||||||
|
|
||||||
const invervalID = setInterval(executeAction, 1000 * SET_INTERVAL_SECONDS);
|
|
||||||
setIntervalId.current = invervalID;
|
|
||||||
|
|
||||||
return () => clearCurrentInterval(invervalID);
|
|
||||||
}, [senderEmailAddress]); // eslint-disable-line react-hooks/exhaustive-deps
|
}, [senderEmailAddress]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Reference in New Issue
Block a user