mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:50:43 -05:00
Correctly remove item + children from fence assorts when running removeFenceOffer()
This commit is contained in:
parent
30507acd1b
commit
96f75fd744
@ -899,18 +899,28 @@ export class FenceService
|
||||
*/
|
||||
public removeFenceOffer(assortIdToRemove: string): void
|
||||
{
|
||||
let relatedAssortIndex = this.fenceAssort.items.findIndex((i) => i._id === assortIdToRemove);
|
||||
|
||||
// No offer found in main assort, check discount items
|
||||
if (relatedAssortIndex === -1)
|
||||
// Assort could have child items, remove those too
|
||||
const itemWithChildrenToRemove = this.itemHelper.findAndReturnChildrenAsItems(this.fenceAssort.items, assortIdToRemove);
|
||||
for (const itemToRemove of itemWithChildrenToRemove)
|
||||
{
|
||||
relatedAssortIndex = this.fenceDiscountAssort.items.findIndex((i) => i._id === assortIdToRemove);
|
||||
this.fenceDiscountAssort.items.splice(relatedAssortIndex, 1);
|
||||
let indexToRemove = this.fenceAssort.items.findIndex(item => item._id === itemToRemove._id);
|
||||
|
||||
return;
|
||||
// No offer found in main assort, check discount items
|
||||
if (indexToRemove === -1)
|
||||
{
|
||||
indexToRemove = this.fenceDiscountAssort.items.findIndex((i) => i._id === itemToRemove._id);
|
||||
this.fenceDiscountAssort.items.splice(indexToRemove, 1);
|
||||
|
||||
if (indexToRemove === -1)
|
||||
{
|
||||
this.logger.warning(`unable to remove fence assort item: ${itemToRemove._id} tpl: ${itemToRemove._tpl}`)
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove offer from assort
|
||||
this.fenceAssort.items.splice(indexToRemove, 1);
|
||||
}
|
||||
|
||||
// Remove offer from assort
|
||||
this.fenceAssort.items.splice(relatedAssortIndex, 1);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user