Skip to content

Commit

Permalink
Registration Refresh
Browse files Browse the repository at this point in the history
- Toss component in Suspense boundary
  • Loading branch information
CannonLock committed Dec 10, 2024
1 parent 25d245b commit f0f2cc9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
8 changes: 5 additions & 3 deletions web_ui/frontend/app/origin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

'use client';

import { useState } from 'react';
import { Box, IconButton, Grid, Tooltip, Typography } from '@mui/material';
import { useState, Suspense } from 'react';
import { Box, IconButton, Grid, Tooltip, Typography, Skeleton } from '@mui/material';
import { Key, CheckCircle } from '@mui/icons-material';

import RateGraph from '@/components/graphs/RateGraph';
Expand Down Expand Up @@ -85,7 +85,9 @@ export default function Home() {
)}
</Tooltip>
</Box>
<DataExportTable />
<Suspense fallback={<Skeleton/>}>
<DataExportTable />
</Suspense>
</Grid>
<Grid item xs={12} lg={6}>
<Box
Expand Down
12 changes: 6 additions & 6 deletions web_ui/frontend/components/DataExportTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import useSWR from 'swr';
import { getErrorMessage } from '@/helpers/util';
import { Capabilities } from '@/types';
import { CapabilitiesDisplay } from '@/components';
import CircularProgress from '@mui/material/CircularProgress';
import { useSearchParams } from 'next/navigation';

type RegistrationStatus =
Expand Down Expand Up @@ -368,10 +367,14 @@ const generateEditUrl = (editUrl: string, fromUrl: string) => {
}

export const DataExportTable = ({ boxProps }: { boxProps?: BoxProps }) => {

const searchParams = useSearchParams()
const from_registry = searchParams.get('from_registry') == 'true'

const [pending, setPending] = useState<boolean>(false);
const [ fromUrl, setFromUrl ] = useState<string | undefined>(undefined);
const { data, mutate } = useSWR('getDataExport', getExportData, {
refreshInterval: 10000
refreshInterval: from_registry ? 10000 : 0,
});

useEffect(() => {
Expand All @@ -380,12 +383,9 @@ export const DataExportTable = ({ boxProps }: { boxProps?: BoxProps }) => {
setTimeout(() => {
mutate()
setPending(false);
}, 5000);
}, 10000);
}, []);

const searchParams = useSearchParams()
const from_registry = searchParams.get('from_registry') == 'true'

const dataEnhanced = useMemo(() => {

// If no from URL return current data
Expand Down

0 comments on commit f0f2cc9

Please sign in to comment.