Skip to content

Commit 1822856

Browse files
committed
update auto refresh logic in ContainerLogModal to handle refetching state
1 parent d19dab8 commit 1822856

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

react/src/components/AutoRefreshSwitch.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
import { useRafInterval } from 'ahooks';
21
import { Switch, SwitchProps, Typography } from 'antd';
32
import { BAIFlex } from 'backend.ai-ui';
43
import React from 'react';
4+
import { useInterval } from 'src/hooks/useIntervalValue';
55

66
const { Text } = Typography;
77

88
interface Props extends SwitchProps {
99
children?: React.ReactNode;
1010
onRefresh: () => void;
11-
interval?: number;
11+
interval: number | null;
1212
}
1313

1414
const AutoRefreshSwitch: React.FC<Props> = ({
1515
children,
16-
interval = 5_000,
16+
interval = null,
1717
onRefresh,
1818
...switchProps
1919
}) => {
20-
useRafInterval(
20+
useInterval(
2121
() => {
2222
onRefresh();
2323
},
24-
switchProps.checked ? interval : undefined,
24+
switchProps.checked ? interval : null,
2525
);
2626

2727
return (

react/src/components/ComputeSessionNodeItems/ContainerLogModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,15 @@ const ContainerLogModal: React.FC<ContainerLogModalProps> = ({
219219
<AutoRefreshSwitch
220220
checked={autoRefreshEnabled}
221221
onChange={setAutoRefreshEnabled}
222-
interval={autoRefreshIntervalValue}
222+
interval={isRefetching ? null : autoRefreshIntervalValue}
223223
onRefresh={() => {
224224
refetch();
225225
}}
226226
>
227227
{t('button.AutoRefresh')}:
228228
</AutoRefreshSwitch>
229229
<InputNumber
230-
min={1}
230+
min={3}
231231
value={(autoRefreshIntervalValue ?? 1000) / 1000}
232232
onChange={(value) => {
233233
if (typeof value === 'number') {

0 commit comments

Comments
 (0)