Skip to content

Commit

Permalink
Preventing cache from displaying wrong contest info
Browse files Browse the repository at this point in the history
  • Loading branch information
rissois committed Aug 30, 2024
1 parent 22b9959 commit e7ac8df
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion react-ui/src/pages/contest/Contest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

import Box from '@material-ui/core/Box';
import CircularProgress from '@material-ui/core/CircularProgress';
import Typography from '@material-ui/core/Typography';
import { makeStyles } from '@material-ui/core/styles';
import clsx from 'clsx';
Expand Down Expand Up @@ -62,7 +63,7 @@ function Contest() {
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
const [drawerEntryId, setDrawerEntryId] = useState(null);

if (contest?.submissionWindowOpen) {
if (contest?.submissionWindowOpen && !isValidating) {
navigate('/submission', { replace: true });
}

Expand Down Expand Up @@ -168,6 +169,27 @@ function Contest() {
categories, isContestMode, name, votingWindowOpen, winners,
} = contest;

// Prevents display of stale, cached data
if (isValidating) {
return (
<PageWithDrawer
isOpen={false}
appBar={{
className: classes.icon,
color: 'default',
right: <ContestAppBarRight {...{ toggleDrawerOpen, contest }} />,
}}
drawer={{ heading: 'Loading...', children: null }}
>
<PageContainer>
<Box marginBottom={6} />
<CircularProgress />
</PageContainer>
<RedditLogInDialog />
</PageWithDrawer>
);
}

return (
<PageWithDrawer
handleClose={closeDrawer}
Expand Down

0 comments on commit e7ac8df

Please sign in to comment.