new pbs are remembered in the result

This commit is contained in:
Jack 2020-09-27 00:10:30 +01:00
parent 9c637a59fa
commit ad661595ec
4 changed files with 18 additions and 3 deletions

View file

@ -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" &&

View file

@ -2907,6 +2907,7 @@
<table width="100%">
<thead>
<tr>
<td></td>
<td>wpm</td>
<td>raw</td>
<td>accuracy</td>

View file

@ -1733,8 +1733,16 @@ function loadMoreLines() {
consistency = consistency.toFixed(2) + "%";
}
let pb = result.isPb;
if (pb) {
pb = '<i class="fas fa-fw fa-crown"></i>'
} else {
pb = '';
}
$(".pageAccount .history table tbody").append(`
<tr>
<td>${pb}</td>
<td>${result.wpm.toFixed(2)}</td>
<td>${raw}</td>
<td>${result.acc.toFixed(2)}%</td>

View file

@ -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) {