diff options
author | Eugene <eug-vs@keemail.me> | 2020-01-12 15:08:34 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-12 15:08:34 +0000 |
commit | 23a5631531861ac76d532c0d9d2b19dd1862f739 (patch) | |
tree | 9c4c7e2c2255d8a7253f5bacebc149cde1dbc696 /src | |
parent | e78ecf560a0c6f4cf59a3c4341884996464c7923 (diff) | |
parent | b5af9d633386e1e9139888cbe272ff4d34e6219b (diff) | |
download | chrono-cube-ui-23a5631531861ac76d532c0d9d2b19dd1862f739.tar.gz |
Merge pull request #31 from Eug-VS/scoreboard-requests
Improve requests logic on Scoreboard page
Diffstat (limited to 'src')
-rw-r--r-- | src/components/Scoreboard/Scoreboard.js | 8 | ||||
-rw-r--r-- | src/components/SolutionCard/SolutionCard.js | 5 |
2 files changed, 6 insertions, 7 deletions
diff --git a/src/components/Scoreboard/Scoreboard.js b/src/components/Scoreboard/Scoreboard.js index 2d9bb80..5c83735 100644 --- a/src/components/Scoreboard/Scoreboard.js +++ b/src/components/Scoreboard/Scoreboard.js @@ -28,18 +28,16 @@ const Scoreboard = () => { const updateSolutions = () => { get('scoreboard/').then(response => { - setTimeout(() => { setSolutions(response.data); - }, 300); }); }; - const removeSolution = (id) => { - setSolutions(solutions.filter((solution => solution.id !== id))); + const removeSolution = id => { + updateSolutions(); }; useEffect(() => { - updateSolutions(); + setTimeout(updateSolutions, 300); }, []); const renderItem = ({ index, style }) => { diff --git a/src/components/SolutionCard/SolutionCard.js b/src/components/SolutionCard/SolutionCard.js index 7cca74c..1fff873 100644 --- a/src/components/SolutionCard/SolutionCard.js +++ b/src/components/SolutionCard/SolutionCard.js @@ -54,9 +54,10 @@ const SolutionCard = ({ data, removeThisCard }) => { }; const handleDelete = () => { - del(`solutions/${data.id}/`); + del(`solutions/${data.id}/`).then(() => { + removeThisCard(data.id); + }); handleClose(); - removeThisCard(data.id); }; return ( |