forked from OpenWF/SpaceNinjaServer
		
	fix: don't duplicate FlavourItems (#1526)
Reviewed-on: OpenWF/SpaceNinjaServer#1526 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									db1dd21924
								
							
						
					
					
						commit
						a8f174bce1
					
				@ -1014,12 +1014,14 @@ export const addCustomization = (
 | 
			
		||||
    customizationName: string,
 | 
			
		||||
    inventoryChanges: IInventoryChanges = {}
 | 
			
		||||
): IInventoryChanges => {
 | 
			
		||||
    const flavourItemIndex = inventory.FlavourItems.push({ ItemType: customizationName }) - 1;
 | 
			
		||||
    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
			
		||||
    inventoryChanges.FlavourItems ??= [];
 | 
			
		||||
    (inventoryChanges.FlavourItems as IFlavourItem[]).push(
 | 
			
		||||
        inventory.FlavourItems[flavourItemIndex].toJSON<IFlavourItem>()
 | 
			
		||||
    );
 | 
			
		||||
    if (!inventory.FlavourItems.find(x => x.ItemType == customizationName)) {
 | 
			
		||||
        const flavourItemIndex = inventory.FlavourItems.push({ ItemType: customizationName }) - 1;
 | 
			
		||||
        // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
			
		||||
        inventoryChanges.FlavourItems ??= [];
 | 
			
		||||
        (inventoryChanges.FlavourItems as IFlavourItem[]).push(
 | 
			
		||||
            inventory.FlavourItems[flavourItemIndex].toJSON<IFlavourItem>()
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    return inventoryChanges;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user