fix(webui): handle config having no worldState entry at all (#2427)
All checks were successful
Build Docker image / docker-amd64 (push) Successful in 47s
Build Docker image / docker-arm64 (push) Successful in 50s
Build / build (push) Successful in 1m13s

Reviewed-on: #2427
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
Sainan 2025-07-06 20:14:05 -07:00 committed by Sainan
parent 80b5e2df7f
commit 1545cdb8ce
3 changed files with 4 additions and 2 deletions

View File

@ -37,6 +37,8 @@ const configIdToIndexable = (id: string): [Record<string, boolean | string | num
let obj = config as unknown as Record<string, never>;
const arr = id.split(".");
while (arr.length > 1) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
obj[arr[0]] ??= {} as never;
obj = obj[arr[0]];
arr.splice(0, 1);
}

View File

@ -870,7 +870,7 @@
</div>
<div class="form-group mt-2">
<label class="form-label" for="worldState.galleonOfGhouls" data-loc="worldState_galleonOfGhouls"></label>
<select class="form-control" id="worldState.galleonOfGhouls" data-default="">
<select class="form-control" id="worldState.galleonOfGhouls" data-default="0">
<option value="0" data-loc="disabled"></option>
<option value="1" data-loc="worldState_we1"></option>
<option value="2" data-loc="worldState_we2"></option>

View File

@ -2010,7 +2010,7 @@ single.getRoute("/webui/cheats").on("beforeload", function () {
if (elm.type == "checkbox") {
elm.checked = value;
} else if (elm.classList.contains("tags-input")) {
elm.value = value.join(", ");
elm.value = (value ?? []).join(", ");
elm.oninput();
} else {
elm.value = value ?? elm.getAttribute("data-default");