fixed update preset config checkbox not working at all

This commit is contained in:
Miodec 2021-08-01 13:20:58 +01:00
parent e991ddf91c
commit 0d778e91d3
2 changed files with 20 additions and 13 deletions

View file

@ -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 {

View file

@ -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);