fixed a bug that would cause the pb object to not be saved correctly

This commit is contained in:
Jack 2020-07-08 16:32:22 +01:00
parent 50c441bee5
commit f31aa80102
2 changed files with 8 additions and 1 deletions

View file

@ -267,6 +267,9 @@ function checkIfPB(uid, obj) {
let toUpdate = false;
let found = false;
try {
if (pbs[obj.mode][obj.mode2] === undefined) {
pbs[obj.mode][obj.mode2] = [];
}
pbs[obj.mode][obj.mode2].forEach((pb) => {
if (
pb.punctuation === obj.punctuation &&
@ -356,7 +359,8 @@ exports.testCompleted = functions.https.onCall((request, response) => {
return -1;
}
db.collection("users")
return db
.collection("users")
.doc(request.uid)
.get()
.then((ret) => {

View file

@ -142,6 +142,9 @@ async function db_saveLocalPB(
function cont() {
try {
let found = false;
if (dbSnapshot.personalBests[mode][mode2] === undefined) {
dbSnapshot.personalBests[mode][mode2] = [];
}
dbSnapshot.personalBests[mode][mode2].forEach((pb) => {
if (
pb.punctuation == punctuation &&