瀏覽代碼

Cleaning up some of the summary transfer logic

Kirk Trombley 5 年之前
父節點
當前提交
bfc171fbf5

+ 8 - 4
client/src/components/screens/GamePanel/GamePanel.jsx

@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useState, useEffect } from 'react';
 import styled from 'styled-components';
 import Loading from '../../util/Loading';
 import GuessPane from "./GuessPane";
@@ -35,11 +35,15 @@ export default () => {
 
   const [submitDisabled, setSubmitDisabled] = useState(false);
   const [selectedPoint, setSelectedPoint] = useState(null);
-  const currentRound = useCurrentRound();
+  const finished = useCurrentRound() === null;
   const targetPoint = useTargetPoint();
+  useEffect(() => { 
+    if (finished) {
+      dispatch.goToSummary();
+    }
+  }, [finished]);
 
-  if (currentRound === null) {
-    dispatch.goToSummary();
+  if (finished) {
     return <Loading/>
   }
 

+ 1 - 1
client/src/components/screens/RoundSummary/NextRoundButton.jsx

@@ -24,7 +24,7 @@ export default () => {
       ? <NextButton onEnd={dispatch.startRound} countDownFormatter={rem => `Click to cancel, ${rem}s...`}>
           Next Round
         </NextButton>
-      : <FinishedButton onClick={dispatch.startRound}>
+      : <FinishedButton onClick={dispatch.goToSummary}>
           View Summary
         </FinishedButton>
   );