From c1f534ec42ad59ed15199060240598e1467d7b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arthur=20Gon=C3=A7alves?= Date: Mon, 11 Sep 2023 12:08:12 +0100 Subject: [PATCH] Use util instead of creating local helper function --- src/libs/RequestThrottle.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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; }