Skip to content

Commit

Permalink
Addre PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Lin Wang <[email protected]>
  • Loading branch information
wanglam committed Sep 27, 2024
1 parent 705c6bc commit 8cbc68c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions public/components/common/refresh_interval.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const intervalUnitOptions = [
{ text: 'hours', value: 'h' },
];

const MAX_SIGNED_32_BIT_INTEGER = 2147483647;

export const RefreshInterval = ({
onRefresh,
onRefreshChange,
Expand Down Expand Up @@ -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));
}
}

Expand Down

0 comments on commit 8cbc68c

Please sign in to comment.