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 ? "✅" : ""}
+
}