From 17e1eb86dd994a56a62945bda512d6103c022743 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Sat, 27 Sep 2025 03:23:53 -0700 Subject: [PATCH] fix(webui): don't send off 2 addXp requests at once (#2815) One would likely fail due to Mongoose's array versioning Closes #2811 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2815 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- static/webui/script.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/static/webui/script.js b/static/webui/script.js index f0c82ac3b..c6400db71 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -837,10 +837,9 @@ function updateInventory() { a.href = "#"; a.onclick = function (event) { event.preventDefault(); - revalidateAuthz().then(() => { - const promises = []; + revalidateAuthz().then(async () => { 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]) { for (const exaltedType of itemMap[item.ItemType].exalted) { @@ -851,20 +850,16 @@ function updateInventory() { const exaltedCap = itemMap[exaltedType]?.type == "weapons" ? 800_000 : 1_600_000; if (exaltedItem.XP < exaltedCap) { - promises.push( - addGearExp( - "SpecialItems", - exaltedItem.ItemId.$oid, - exaltedCap - exaltedItem.XP - ) + await addGearExp( + "SpecialItems", + exaltedItem.ItemId.$oid, + exaltedCap - exaltedItem.XP ); } } } } - Promise.all(promises).then(() => { - updateInventory(); - }); + updateInventory(); }); }; a.title = loc("code_maxRank");