update ItemCount if EmailItem allows multiples
All checks were successful
Build / build (18) (push) Successful in 56s
Build / build (20) (push) Successful in 57s
Build / build (22) (push) Successful in 39s
Build / build (22) (pull_request) Successful in 37s
Build / build (20) (pull_request) Successful in 56s
Build / build (18) (pull_request) Successful in 1m0s

This commit is contained in:
Sainan 2025-03-06 17:06:16 +01:00
parent 26ad8fceff
commit 514e306394

View File

@ -946,11 +946,16 @@ export const addEmailItem = async (
typeName: string, typeName: string,
inventoryChanges: IInventoryChanges = {} inventoryChanges: IInventoryChanges = {}
): Promise<IInventoryChanges> => { ): Promise<IInventoryChanges> => {
const emailItem = ExportEmailItems[typeName]; const meta = ExportEmailItems[typeName];
if (!emailItem.sendOnlyOnce || !inventory.EmailItems.find(x => x.ItemType == typeName)) { const emailItem = inventory.EmailItems.find(x => x.ItemType == typeName);
await createMessage(inventory.accountOwnerId.toString(), [convertInboxMessage(emailItem.message)]); if (!emailItem || !meta.sendOnlyOnce) {
await createMessage(inventory.accountOwnerId.toString(), [convertInboxMessage(meta.message)]);
inventory.EmailItems.push({ ItemType: typeName, ItemCount: 1 }); if (emailItem) {
emailItem.ItemCount += 1;
} else {
inventory.EmailItems.push({ ItemType: typeName, ItemCount: 1 });
}
inventoryChanges.EmailItems ??= []; inventoryChanges.EmailItems ??= [];
inventoryChanges.EmailItems.push({ ItemType: typeName, ItemCount: 1 }); inventoryChanges.EmailItems.push({ ItemType: typeName, ItemCount: 1 });