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 @@
| wpm | raw | accuracy | 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(`|
| ${pb} | ${result.wpm.toFixed(2)} | ${raw} | ${result.acc.toFixed(2)}% | 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) {