From ad661595eccb416872e228460d7200d93170e061 Mon Sep 17 00:00:00 2001 From: Jack Date: Sun, 27 Sep 2020 00:10:30 +0100 Subject: [PATCH] new pbs are remembered in the result --- functions/index.js | 7 +++++-- public/index.html | 1 + public/js/account.js | 8 ++++++++ public/js/script.js | 5 ++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/functions/index.js b/functions/index.js index deb116042..6507c9610 100644 --- a/functions/index.js +++ b/functions/index.js @@ -829,12 +829,11 @@ exports.testCompleted = functions ), checkIfPB(request.uid, request.obj, userdata), ]) - .then((values) => { + .then(async (values) => { let globallb = values[0].insertedAt; let dailylb = values[1].insertedAt; let ispb = values[2]; // console.log(values); - incrementTestCounter(request.uid, userdata); incrementStartedTestCounter( request.uid, @@ -891,6 +890,10 @@ exports.testCompleted = functions request.uid } (new PB) - ${JSON.stringify(logobj)}` ); + await db + .collection(`users/${request.uid}/results/`) + .doc(createdDocId) + .update({ isPb: true }); if ( obj.mode === "time" && String(obj.mode2) === "60" && diff --git a/public/index.html b/public/index.html index e297d7095..27492885d 100644 --- a/public/index.html +++ b/public/index.html @@ -2907,6 +2907,7 @@ + diff --git a/public/js/account.js b/public/js/account.js index 21b14d5cd..0593150d6 100644 --- a/public/js/account.js +++ b/public/js/account.js @@ -1733,8 +1733,16 @@ function loadMoreLines() { consistency = consistency.toFixed(2) + "%"; } + let pb = result.isPb; + if (pb) { + pb = '' + } else { + pb = ''; + } + $(".pageAccount .history table tbody").append(` + diff --git a/public/js/script.js b/public/js/script.js index bba177315..e9e5e4ea2 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -1991,6 +1991,9 @@ function showResult(difficultyFailed = false) { ); } else if (e.data.resultCode === 1 || e.data.resultCode === 2) { completedEvent.id = e.data.createdId; + if (e.data.resultCode === 2) { + completedEvent.isPb = true; + } if (dbSnapshot !== null && dbSnapshot.results !== undefined) { dbSnapshot.results.unshift(completedEvent); if (dbSnapshot.globalStats.time == undefined) { @@ -2193,7 +2196,7 @@ function showResult(difficultyFailed = false) { config.difficulty, stats.wpm, stats.acc, - stats.wpmRaw + stats.wpmRaw, ); } else if (e.data.resultCode === 1) { if (localPb) {
wpm raw accuracy
${pb} ${result.wpm.toFixed(2)} ${raw} ${result.acc.toFixed(2)}%