diff options
author | Eug-VS <eug-vs@keemail.me> | 2020-01-06 01:53:47 +0300 |
---|---|---|
committer | Eug-VS <eug-vs@keemail.me> | 2020-01-06 01:53:47 +0300 |
commit | f76a0f4b0e488530c1e715ecaa824fca7790dddd (patch) | |
tree | 1e376c7ea4700e5f3567ac09cb3bcc70654625cf /src | |
parent | 4e82e018e1fd88e24886362db864ae7d0d73cc7b (diff) | |
download | chrono-cube-ui-f76a0f4b0e488530c1e715ecaa824fca7790dddd.tar.gz |
Delay scoreboard update, add progress indicator
Wait for the Header>Tabs>Indicator to get into place so it doesn't
freeze when it comes to rendering new massive frame.
Diffstat (limited to 'src')
-rw-r--r-- | src/components/Scoreboard/Scoreboard.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/components/Scoreboard/Scoreboard.js b/src/components/Scoreboard/Scoreboard.js index 47e306e..93ec2f0 100644 --- a/src/components/Scoreboard/Scoreboard.js +++ b/src/components/Scoreboard/Scoreboard.js @@ -6,25 +6,30 @@ import { Grid, } from "@material-ui/core"; +import { makeStyles } from "@material-ui/core/styles"; +import LinearProgress from '@material-ui/core/LinearProgress'; + import { get } from "../../requests"; import SolutionCard from "../SolutionCard/SolutionCard"; -import { makeStyles } from "@material-ui/core/styles"; const useStyles = makeStyles(theme => ({ pageHeader: { textAlign: 'center', margin: theme.spacing(2), - } + }, })); const Scoreboard = () => { const classes = useStyles(); const [solutions, setSolutions] = useState([]); - const updateSolutions = async () => { - const response = await get('solutions/'); - await setSolutions(response.data); + const updateSolutions = () => { + get('solutions/').then(response => { + setTimeout(() => { + setSolutions(response.data); + }, 250); + }); }; const removeSolution = (id) => { @@ -40,6 +45,7 @@ const Scoreboard = () => { <Typography variant="h3" className={classes.pageHeader}> Scoreboard </Typography> + {(solutions.length === 0) && <LinearProgress color="secondary" />} <Grid container justify="center" direction="column" spacing={3}> {solutions.map(solution => ( <Grid item key={solution.id}> |