From 8cbc68cd98bac2189e1b89fc530e9b589b862388 Mon Sep 17 00:00:00 2001 From: Lin Wang Date: Fri, 27 Sep 2024 11:29:04 +0800 Subject: [PATCH] Addre PR comments Signed-off-by: Lin Wang --- public/components/common/refresh_interval.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/public/components/common/refresh_interval.tsx b/public/components/common/refresh_interval.tsx index 1cc6762e..9bc24264 100644 --- a/public/components/common/refresh_interval.tsx +++ b/public/components/common/refresh_interval.tsx @@ -38,6 +38,8 @@ const intervalUnitOptions = [ { text: 'hours', value: 'h' }, ]; +const MAX_SIGNED_32_BIT_INTEGER = 2147483647; + export const RefreshInterval = ({ onRefresh, onRefreshChange, @@ -100,12 +102,12 @@ export const RefreshInterval = ({ if (interval !== null) { /** * According https://developer.mozilla.org/en-US/docs/Web/API/setInterval#return_value - * the max delayed value of setInterval is 2147483647, the inner function will be executed immediately - * if the delayed value is greater than 2147483647. Add a Math.min here to avoid been executed immediately. + * the max delayed value of setInterval is MAX_SIGNED_32_BIT_INTEGER, the inner function will be executed immediately + * if the delayed value is greater than MAX_SIGNED_32_BIT_INTEGER. Add a Math.min here to avoid been executed immediately. **/ intervalId = window.setInterval(() => { onRefresh(); - }, Math.min(interval, 2147483647)); + }, Math.min(interval, MAX_SIGNED_32_BIT_INTEGER)); } }