From 9ec386414c21f436d50309b716063f3366a9f8f1 Mon Sep 17 00:00:00 2001 From: Tim Glasgow Date: Sat, 6 Aug 2022 17:37:52 -0500 Subject: [PATCH] commit scores to realm --- squarenotsquare/src/redux/actions/UserActions.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/squarenotsquare/src/redux/actions/UserActions.js b/squarenotsquare/src/redux/actions/UserActions.js index d64eadf..66d0c40 100644 --- a/squarenotsquare/src/redux/actions/UserActions.js +++ b/squarenotsquare/src/redux/actions/UserActions.js @@ -1,5 +1,7 @@ import { squareNav } from "../../navigation/SquareNav"; import { SQUARE_FINISHED, SQUARE_START } from "../types/UserTypes"; +import { calculateSquareScore } from "../../libs/CalculateScore"; +import DbAPI from "../../realm/DbAPI"; export function squareStartPressed() { return (dispatch) => { @@ -17,6 +19,9 @@ export function squareFinished(answers, finalTime) { let newUser = {...userState}; newUser.lastGameTime = finalTime; newUser.lastGameAnswers = answers; + + let finalScore = calculateSquareScore(answers, finalTime); + DbAPI.createScore(userState.username, finalScore); dispatch({ type: SQUARE_FINISHED, user: newUser