From 05b7b8c37f7a3fe3f931dcf854475429771a8749 Mon Sep 17 00:00:00 2001 From: Jack Date: Sun, 30 Aug 2020 06:32:22 +0100 Subject: [PATCH] saving the last result when a user signs up --- public/js/account.js | 9 +++++++++ public/js/script.js | 2 ++ 2 files changed, 11 insertions(+) diff --git a/public/js/account.js b/public/js/account.js index 2a0aaba93..1fa8c1bdf 100644 --- a/public/js/account.js +++ b/public/js/account.js @@ -154,6 +154,15 @@ function signUp() { personalBests: {}, tags: [], }; + if (notSignedInLastResult !== null) { + notSignedInLastResult.uid = usr.uid; + testCompleted({ + uid: usr.uid, + obj: notSignedInLastResult, + }); + dbSnapshot.results.push(notSignedInLastResult); + config.resultFilters = defaultAccountFilters; + } changePage("account"); }) .catch(function (error) { diff --git a/public/js/script.js b/public/js/script.js index 6dc7dc202..07a425847 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -36,6 +36,7 @@ let focusState = false; let activeFunBox = "none"; let manualRestart = false; let bailout = false; +let notSignedInLastResult = null; let themeColors = { bg: "#323437", @@ -1947,6 +1948,7 @@ function showResult(difficultyFailed = false) { } catch (e) { console.log("Analytics unavailable"); } + notSignedInLastResult = completedEvent; // showNotification("Sign in to save your result",3000); }