mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-03-13 07:23:39 +08:00
Merge pull request #998 from bsamseth/master
Add option to reset personal bests (#980)
This commit is contained in:
commit
c732b441f4
6 changed files with 73 additions and 34 deletions
|
@ -455,6 +455,22 @@ 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: {} });
|
||||
} catch (e) {
|
||||
console.log(
|
||||
`something went wrong when deleting personal bests for ${uid}: ${e.message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
function checkIfPB(uid, obj, userdata) {
|
||||
let pbs = null;
|
||||
if (obj.mode == "quote") {
|
||||
|
|
|
@ -34,3 +34,6 @@ export const changeDisplayName = firebase
|
|||
export const removeSmallTests = firebase
|
||||
.functions()
|
||||
.httpsCallable("removeSmallTestsAndQPB");
|
||||
export const resetPersonalBests = firebase
|
||||
.functions()
|
||||
.httpsCallable("resetPersonalBests");
|
||||
|
|
|
@ -226,3 +226,30 @@ simplePopups.applyCustomFont = new SimplePopup(
|
|||
},
|
||||
() => {}
|
||||
);
|
||||
|
||||
simplePopups.resetPersonalBests = new SimplePopup(
|
||||
"resetPersonalBests",
|
||||
"text",
|
||||
"Reset Personal Bests",
|
||||
[],
|
||||
"Are you sure you want to reset all your personal bests?",
|
||||
"Reset",
|
||||
() => {
|
||||
try {
|
||||
showBackgroundLoader();
|
||||
|
||||
CloudFunctions.resetPersonalBests({
|
||||
uid: firebase.auth().currentUser.uid,
|
||||
}).then(() => {
|
||||
hideBackgroundLoader();
|
||||
Notifications.add("Personal bests removed, refreshing the page...", 0);
|
||||
setTimeout(() => {
|
||||
location.reload();
|
||||
}, 2000);
|
||||
});
|
||||
} catch (e) {
|
||||
Notifications.add("Something went wrong: " + e, -1);
|
||||
}
|
||||
},
|
||||
() => {}
|
||||
);
|
||||
|
|
|
@ -3095,6 +3095,23 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section resetPersonalBests">
|
||||
<h1>reset personal bests</h1>
|
||||
<div class="text">
|
||||
Resets all your personal bests (but doesn't delete any tests
|
||||
from your history). Warning: you can't undo this action!
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<div
|
||||
class="button off danger"
|
||||
id="resetPersonalBestsButton"
|
||||
tabindex="0"
|
||||
onclick="this.blur();simplePopups.resetPersonalBests.show();"
|
||||
>
|
||||
reset personal bests
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section updateAccountEmail">
|
||||
<h1>update account email</h1>
|
||||
<div class="text">
|
||||
|
|
|
@ -1,22 +1,10 @@
|
|||
{
|
||||
"language": "english",
|
||||
"groups": [
|
||||
[
|
||||
0,
|
||||
100
|
||||
],
|
||||
[
|
||||
101,
|
||||
300
|
||||
],
|
||||
[
|
||||
301,
|
||||
600
|
||||
],
|
||||
[
|
||||
601,
|
||||
9999
|
||||
]
|
||||
[0, 100],
|
||||
[101, 300],
|
||||
[301, 600],
|
||||
[601, 9999]
|
||||
],
|
||||
"quotes": [
|
||||
{
|
||||
|
@ -32000,4 +31988,4 @@
|
|||
"id": 5382
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,10 @@
|
|||
{
|
||||
"language": "italian",
|
||||
"groups": [
|
||||
[
|
||||
0,
|
||||
100
|
||||
],
|
||||
[
|
||||
101,
|
||||
300
|
||||
],
|
||||
[
|
||||
301,
|
||||
600
|
||||
],
|
||||
[
|
||||
601,
|
||||
9999
|
||||
]
|
||||
[0, 100],
|
||||
[101, 300],
|
||||
[301, 600],
|
||||
[601, 9999]
|
||||
],
|
||||
"quotes": [
|
||||
{
|
||||
|
@ -44,4 +32,4 @@
|
|||
"id": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue