forked from OpenWF/SpaceNinjaServer
chrore(webui): don't add duplicates to datalists (#1510)
Browsers will show all options, even if this makes no sense, causing some confusion for users. Reviewed-on: OpenWF/SpaceNinjaServer#1510 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:
parent
7f69667171
commit
ef4973e694
@ -265,6 +265,7 @@ function fetchItemList() {
|
||||
} else if (type == "uniqueLevelCaps") {
|
||||
uniqueLevelCaps = items;
|
||||
} else {
|
||||
const nameSet = new Set();
|
||||
items.forEach(item => {
|
||||
if (item.name.includes("<ARCHWING> ")) {
|
||||
item.name = item.name.replace("<ARCHWING> ", "");
|
||||
@ -311,20 +312,19 @@ function fetchItemList() {
|
||||
document
|
||||
.getElementById("datalist-" + type + "-" + item.partType.slice(5))
|
||||
.appendChild(option);
|
||||
}
|
||||
} else if (item.badReason != "notraw") {
|
||||
if (nameSet.has(item.name)) {
|
||||
//console.log(`Not adding ${item.uniqueName} to datalist for ${type} due to duplicate display name: ${item.name}`);
|
||||
} else {
|
||||
console.log(item.partType);
|
||||
nameSet.add(item.name);
|
||||
|
||||
const option = document.createElement("option");
|
||||
option.setAttribute("data-key", item.uniqueName);
|
||||
option.value = item.name;
|
||||
document.getElementById("datalist-" + type).appendChild(option);
|
||||
}
|
||||
}
|
||||
if (item.badReason != "notraw") {
|
||||
const option = document.createElement("option");
|
||||
option.setAttribute("data-key", item.uniqueName);
|
||||
option.value = item.name;
|
||||
document.getElementById("datalist-" + type).appendChild(option);
|
||||
}
|
||||
itemMap[item.uniqueName] = { ...item, type };
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user