chore: use mongoose's 'id' function in addGearExpByCategory #892

Merged
Sainan merged 1 commits from addxp-id into main 2025-02-03 13:20:57 -08:00

View File

@ -823,12 +823,10 @@ export const addGearExpByCategory = (
return; return;
} }
const itemIndex = ItemId ? category.findIndex(item => item._id?.equals(ItemId.$oid)) : -1; const item = category.id(ItemId.$oid);
if (itemIndex !== -1) { if (item) {
const item = category[itemIndex];
item.XP ??= 0; item.XP ??= 0;
item.XP += XP; item.XP += XP;
inventory.markModified(`${categoryName}.${itemIndex}.XP`);
const xpinfoIndex = inventory.XPInfo.findIndex(x => x.ItemType == item.ItemType); const xpinfoIndex = inventory.XPInfo.findIndex(x => x.ItemType == item.ItemType);
if (xpinfoIndex !== -1) { if (xpinfoIndex !== -1) {