From ca93360971096f72e2b67f084fa34f4781c4851d Mon Sep 17 00:00:00 2001 From: Tim Glasgow Date: Sat, 6 Aug 2022 14:32:58 -0500 Subject: [PATCH] shallow copy redux state --- squarenotsquare/src/redux/actions/UserActions.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/squarenotsquare/src/redux/actions/UserActions.js b/squarenotsquare/src/redux/actions/UserActions.js index 7bd1930..d64eadf 100644 --- a/squarenotsquare/src/redux/actions/UserActions.js +++ b/squarenotsquare/src/redux/actions/UserActions.js @@ -10,14 +10,16 @@ export function squareStartPressed() { } } -export function squareFinished(score, finalTime) { +export function squareFinished(answers, finalTime) { return (dispatch, getState) => { - squareNav('Score'); - let newUser = getState().user; + setTimeout(() => squareNav('Score'), 3000); + const userState = getState().user; + let newUser = {...userState}; newUser.lastGameTime = finalTime; - newUser.lastGameScore = score; + newUser.lastGameAnswers = answers; dispatch({ - type: SQUARE_FINISHED + type: SQUARE_FINISHED, + user: newUser }); } } \ No newline at end of file