mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-03-12 23:20:25 +08:00
fixed update preset config checkbox not working at all
This commit is contained in:
parent
e991ddf91c
commit
0d778e91d3
2 changed files with 20 additions and 13 deletions
|
@ -1953,13 +1953,14 @@ exports.editPreset = functions.https.onCall((request, response) => {
|
|||
if (!isTagPresetNameValid(request.name)) {
|
||||
return { resultCode: -1 };
|
||||
} else {
|
||||
let set = {
|
||||
name: request.name,
|
||||
};
|
||||
if (request.config) set.config = request.config;
|
||||
return db
|
||||
.collection(`users/${request.uid}/presets`)
|
||||
.doc(request.presetid)
|
||||
.set({
|
||||
config: request.config,
|
||||
name: request.name,
|
||||
})
|
||||
.set(set)
|
||||
.then((e) => {
|
||||
console.log(`user ${request.uid} updated a preset: ${request.name}`);
|
||||
return {
|
||||
|
|
|
@ -67,14 +67,20 @@ function apply() {
|
|||
let action = $("#presetWrapper #presetEdit").attr("action");
|
||||
let inputVal = $("#presetWrapper #presetEdit input").val();
|
||||
let presetid = $("#presetWrapper #presetEdit").attr("presetid");
|
||||
let configChanges = Config.getConfigChanges();
|
||||
let activeTagIds = [];
|
||||
DB.getSnapshot().tags.forEach((tag) => {
|
||||
if (tag.active) {
|
||||
activeTagIds.push(tag.id);
|
||||
}
|
||||
});
|
||||
configChanges.tags = activeTagIds;
|
||||
let updateConfig = $("#presetWrapper #presetEdit label input").prop(
|
||||
"checked"
|
||||
);
|
||||
let configChanges = null;
|
||||
if (updateConfig) {
|
||||
configChanges = Config.getConfigChanges();
|
||||
let activeTagIds = [];
|
||||
DB.getSnapshot().tags.forEach((tag) => {
|
||||
if (tag.active) {
|
||||
activeTagIds.push(tag.id);
|
||||
}
|
||||
});
|
||||
configChanges.tags = activeTagIds;
|
||||
}
|
||||
hide();
|
||||
if (action === "add") {
|
||||
Loader.show();
|
||||
|
@ -119,7 +125,7 @@ function apply() {
|
|||
(preset) => preset.id == presetid
|
||||
)[0];
|
||||
preset.name = inputVal;
|
||||
preset.config = configChanges;
|
||||
if (configChanges) preset.config = configChanges;
|
||||
Settings.update();
|
||||
} else if (status === -1) {
|
||||
Notifications.add("Invalid preset name", 0);
|
||||
|
|
Loading…
Reference in a new issue