mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-11 00:03:44 +08:00
added local tag pb get and set function
This commit is contained in:
parent
5080733b7f
commit
07891e306a
1 changed files with 37 additions and 0 deletions
37
src/js/db.js
37
src/js/db.js
|
@ -245,3 +245,40 @@ export async function db_saveLocalPB(
|
|||
cont();
|
||||
}
|
||||
}
|
||||
|
||||
export async function db_getLocalTagPB(tagId) {
|
||||
function cont() {
|
||||
let ret = 0;
|
||||
try {
|
||||
ret = dbSnapshot.tags.filter((t) => t.id === tagId)[0].pb;
|
||||
if (ret == undefined) {
|
||||
ret = 0;
|
||||
}
|
||||
return ret;
|
||||
} catch (e) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
let retval;
|
||||
if (dbSnapshot == null) {
|
||||
} else {
|
||||
retval = cont();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
export async function db_saveLocalTagPB(tagId, wpm) {
|
||||
function cont() {
|
||||
dbSnapshot.tags.forEach((tag) => {
|
||||
if (tag.id === tagId) {
|
||||
tag.pb = wpm;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (dbSnapshot == null) {
|
||||
} else {
|
||||
cont();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue