Handle when foldItem() tries to modify an item without a upd object

This commit is contained in:
Dev 2024-02-20 14:17:04 +00:00
parent 867b1ea50f
commit 6cda845f1f

View File

@ -340,8 +340,8 @@ export class InventoryController
): IItemEventRouterResponse ): IItemEventRouterResponse
{ {
const inventoryItems = this.inventoryHelper.getOwnerInventoryItems(body, sessionID); const inventoryItems = this.inventoryHelper.getOwnerInventoryItems(body, sessionID);
const sourceItem = inventoryItems.from.find(item => item._id == body.item); const sourceItem = inventoryItems.from.find((item) => item._id == body.item);
const destinationItem = inventoryItems.to.find(item => item._id == body.with); const destinationItem = inventoryItems.to.find((item) => item._id == body.with);
if (sourceItem === null) if (sourceItem === null)
{ {
@ -458,6 +458,11 @@ export class InventoryController
{ {
if (item._id && item._id === body.item) if (item._id && item._id === body.item)
{ {
if (!item.upd)
{
item.upd = {};
}
item.upd.Foldable = { Folded: body.value }; item.upd.Foldable = { Folded: body.value };
return this.eventOutputHolder.getOutput(sessionID); return this.eventOutputHolder.getOutput(sessionID);
} }