web: reduce polling interval
The operations will usually take half a second.
This commit is contained in:
parent
c6ebe5a360
commit
1ff1cae709
@ -19,12 +19,12 @@ interface Operation {
|
|||||||
export default function OperationStatusPage() {
|
export default function OperationStatusPage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { operationId } = useParams();
|
const { operationId } = useParams();
|
||||||
|
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [operation, setOperation] = useState<Operation | null>(null);
|
const [operation, setOperation] = useState<Operation | null>(null);
|
||||||
|
|
||||||
const intervalRef = useRef<NodeJS.Timeout | null>(null);
|
const intervalRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!operationId) return;
|
if (!operationId) return;
|
||||||
@ -55,7 +55,7 @@ export default function OperationStatusPage() {
|
|||||||
|
|
||||||
fetchOperation();
|
fetchOperation();
|
||||||
if (!intervalRef.current) {
|
if (!intervalRef.current) {
|
||||||
intervalRef.current = setInterval(fetchOperation, 5000);
|
intervalRef.current = setInterval(fetchOperation, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
@ -77,9 +77,9 @@ export default function OperationStatusPage() {
|
|||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getStatusClass = (status: number) => getStatusText(status).toLowerCase();
|
const getStatusClass = (status: number) => getStatusText(status).toLowerCase();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Webpage>
|
<Webpage>
|
||||||
<main className="operation-status">
|
<main className="operation-status">
|
||||||
@ -99,7 +99,7 @@ export default function OperationStatusPage() {
|
|||||||
<Typography>Owner: {operation.Owner}</Typography>
|
<Typography>Owner: {operation.Owner}</Typography>
|
||||||
<Typography>Date: {new Date(operation.Date * 1000).toLocaleString()}</Typography>
|
<Typography>Date: {new Date(operation.Date * 1000).toLocaleString()}</Typography>
|
||||||
<Typography>Path: {operation.Path}</Typography>
|
<Typography>Path: {operation.Path}</Typography>
|
||||||
|
|
||||||
{operation.Status === 1 && (
|
{operation.Status === 1 && (
|
||||||
<div className="submission-button">
|
<div className="submission-button">
|
||||||
<Button
|
<Button
|
||||||
@ -119,4 +119,4 @@ export default function OperationStatusPage() {
|
|||||||
</main>
|
</main>
|
||||||
</Webpage>
|
</Webpage>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user