From 36682d67fb5d31ead4e2f8b6a14e9c536a57ecdc Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Sat, 18 Sep 2021 23:30:15 -0400 Subject: [PATCH] better formatting --- src/games/GameCore.tsx | 26 ++++++++++++++------------ src/games/GameDisplay.tsx | 7 ++++++- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/games/GameCore.tsx b/src/games/GameCore.tsx index a77d371..63e9c2a 100644 --- a/src/games/GameCore.tsx +++ b/src/games/GameCore.tsx @@ -27,7 +27,7 @@ function GameCore({ questions, Display, timeLimit, Instructions, studyLink, i }) { // TODO: report pass with id to user info const rewardRef = useRef(null); - const { user } = useUser(); + const { user, pullUser } = useUser(); const [finish, setFinish] = useState(null); const [current, setCurrent] = useState | undefined>(undefined); const [questionBox, setQuestionBox] = useState>(questions()); @@ -50,17 +50,19 @@ function GameCore({ questions, Display, timeLimit, Instructions, studyLink, i function handleFinish() { setFinish("pass"); rewardRef.current?.rewardMe(); - if (user) { - const result: AT.TestResult = { - done: true, - time: getTimestamp(), - id, - }; - console.log("will post result", JSON.stringify(result)); - postTestResults([result]) - .then(console.log) - .catch(console.error); - } + if (!user) return; + const result: AT.TestResult = { + done: true, + time: getTimestamp(), + id, + }; + console.log("will post result", JSON.stringify(result)); + postTestResults([result]) + .then((res) => { + if (res.ok) { + pullUser(); + } + }).catch(console.error); } function handleQuit() { setFinish(null); diff --git a/src/games/GameDisplay.tsx b/src/games/GameDisplay.tsx index d6e1512..1a71b5e 100644 --- a/src/games/GameDisplay.tsx +++ b/src/games/GameDisplay.tsx @@ -7,7 +7,12 @@ function GameDisplay({ record: { title, Game, id } }: { record: GameRecord }) { (t.done === true) && (t.id === id) )); return
-

🎮 {title} {completed ? "✅" : ""}

+
+
+

🎮 {title}

+
+
{completed ? "✅" : ""}
+
}