fix(webui): don't send off 2 addXp requests at once

One would likely fail due to Mongoose's array versioning
This commit is contained in:
Sainan 2025-09-26 15:29:31 +02:00
parent de9dfb3d71
commit 3684fc476e

View File

@ -837,10 +837,9 @@ function updateInventory() {
a.href = "#"; a.href = "#";
a.onclick = function (event) { a.onclick = function (event) {
event.preventDefault(); event.preventDefault();
revalidateAuthz().then(() => { revalidateAuthz().then(async () => {
const promises = [];
if (item.XP < maxXP) { if (item.XP < maxXP) {
promises.push(addGearExp(category, item.ItemId.$oid, maxXP - item.XP)); await addGearExp(category, item.ItemId.$oid, maxXP - item.XP);
} }
if ("exalted" in itemMap[item.ItemType]) { if ("exalted" in itemMap[item.ItemType]) {
for (const exaltedType of itemMap[item.ItemType].exalted) { for (const exaltedType of itemMap[item.ItemType].exalted) {
@ -851,20 +850,16 @@ function updateInventory() {
const exaltedCap = const exaltedCap =
itemMap[exaltedType]?.type == "weapons" ? 800_000 : 1_600_000; itemMap[exaltedType]?.type == "weapons" ? 800_000 : 1_600_000;
if (exaltedItem.XP < exaltedCap) { if (exaltedItem.XP < exaltedCap) {
promises.push( await addGearExp(
addGearExp( "SpecialItems",
"SpecialItems", exaltedItem.ItemId.$oid,
exaltedItem.ItemId.$oid, exaltedCap - exaltedItem.XP
exaltedCap - exaltedItem.XP
)
); );
} }
} }
} }
} }
Promise.all(promises).then(() => { updateInventory();
updateInventory();
});
}); });
}; };
a.title = loc("code_maxRank"); a.title = loc("code_maxRank");