diff --git a/src/libs/RequestThrottle.ts b/src/libs/RequestThrottle.ts index 9acdc9650f05..7a9c244e2034 100644 --- a/src/libs/RequestThrottle.ts +++ b/src/libs/RequestThrottle.ts @@ -1,4 +1,5 @@ import CONST from '../CONST'; +import {generateRandomInt} from './NumberUtils'; let requestWaitTime = 0; @@ -6,15 +7,11 @@ function clear(): void { requestWaitTime = 0; } -function getRandomInt(min: number, max: number): number { - return Math.floor(Math.random() * (max - min + 1)) + min; -} - function getRequestWaitTime() { if (requestWaitTime) { requestWaitTime = Math.min(requestWaitTime * 2, CONST.NETWORK.MAX_RETRY_WAIT_TIME_MS); } else { - requestWaitTime = getRandomInt(CONST.NETWORK.MIN_RETRY_WAIT_TIME_MS, CONST.NETWORK.MAX_RANDOM_RETRY_WAIT_TIME_MS); + requestWaitTime = generateRandomInt(CONST.NETWORK.MIN_RETRY_WAIT_TIME_MS, CONST.NETWORK.MAX_RANDOM_RETRY_WAIT_TIME_MS); } return requestWaitTime; }