Skip to content

Commit

Permalink
Merge pull request #210 from tosuapp/fix/settings-order
Browse files Browse the repository at this point in the history
fix: Fix out of order replacement & `undefined` values
  • Loading branch information
KotRikD authored Oct 30, 2024
2 parents 2d5ac58 + de464b6 commit 2f2dbe4
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions packages/server/assets/homepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,6 @@ const showSettings = {
const setting = props.settings[i];
let value = props.values[setting.uniqueID] ?? setting.value;


if (setting.type == "commands") {
setting.options.forEach(r => {
if (r.values) r.values = r.values.filter(r => r !== '' && r != null);
Expand All @@ -641,14 +640,12 @@ const showSettings = {

setting.value.forEach((command, cmd_ind) => {
setting.options.forEach(option => {
const original = setting.value[cmd_ind][option.name];
const modified = value[cmd_ind][option.name];

if (modified == null) return;
const original = command[option.name];
const modified = value.find(r => r[setting.uniqueCheck] == command[setting.uniqueCheck])?.[option.name];
if (original == modified) return;

setting.value[cmd_ind][option.name] = modified;
})
setting.value[cmd_ind][option.name] = modified ?? original;
});
});


Expand Down

0 comments on commit 2f2dbe4

Please sign in to comment.