removed console log, checking return value

This commit is contained in:
Miodec 2021-02-18 22:47:01 +00:00
parent c732b441f4
commit 29ab060054
2 changed files with 18 additions and 7 deletions

View file

@ -457,16 +457,17 @@ exports.removeSmallTestsAndQPB = functions.https.onCall(
exports.resetPersonalBests = functions.https.onCall(
async (request, response) => {
console.log("heyheyhey");
let uid = request.uid;
try {
var user = await db.collection("users").doc(uid);
await user.update({ personalBests: {} });
return true;
} catch (e) {
console.log(
`something went wrong when deleting personal bests for ${uid}: ${e.message}`
);
return false;
}
}
);

View file

@ -240,12 +240,22 @@ simplePopups.resetPersonalBests = new SimplePopup(
CloudFunctions.resetPersonalBests({
uid: firebase.auth().currentUser.uid,
}).then(() => {
hideBackgroundLoader();
Notifications.add("Personal bests removed, refreshing the page...", 0);
setTimeout(() => {
location.reload();
}, 2000);
}).then((res) => {
if (res) {
hideBackgroundLoader();
Notifications.add(
"Personal bests removed, refreshing the page...",
0
);
setTimeout(() => {
location.reload();
}, 1500);
} else {
Notifications.add(
"Something went wrong while removing personal bests...",
-1
);
}
});
} catch (e) {
Notifications.add("Something went wrong: " + e, -1);