From dc96308f94486c5509fcae69f3f38200fbcbc8d7 Mon Sep 17 00:00:00 2001 From: Miodec Date: Mon, 30 May 2022 18:10:01 +0200 Subject: [PATCH] fixed last result not begin saved when using google sign in. closes #3040 --- .../src/ts/controllers/account-controller.ts | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/frontend/src/ts/controllers/account-controller.ts b/frontend/src/ts/controllers/account-controller.ts index fc5916f8b..4a405a923 100644 --- a/frontend/src/ts/controllers/account-controller.ts +++ b/frontend/src/ts/controllers/account-controller.ts @@ -256,6 +256,22 @@ export async function loadUser(user: UserType): Promise { if (VerificationController.data !== null) { VerificationController.verify(user.uid); } + + if (TestLogic.notSignedInLastResult !== null) { + TestLogic.setNotSignedInUid(user.uid); + + const response = await Ape.results.save(TestLogic.notSignedInLastResult); + + if (response.status !== 200) { + return Notifications.add( + "Failed to save last result: " + response.message, + -1 + ); + } + + TestLogic.clearNotSignedInResult(); + Notifications.add("Last test result saved", 1); + } } const authListener = Auth.onAuthStateChanged(async function (user) { @@ -313,23 +329,6 @@ export function signIn(): void { return signInWithEmailAndPassword(Auth, email, password) .then(async (e) => { await loadUser(e.user); - if (TestLogic.notSignedInLastResult !== null) { - TestLogic.setNotSignedInUid(e.user.uid); - - const response = await Ape.results.save( - TestLogic.notSignedInLastResult - ); - - if (response.status !== 200) { - return Notifications.add( - "Failed to save last result: " + response.message, - -1 - ); - } - - TestLogic.clearNotSignedInResult(); - Notifications.add("Last test result saved", 1); - } }) .catch(function (error) { let message = error.message;