From bbe3221229e66fa48f19ee3e6580ced9c7b912ab Mon Sep 17 00:00:00 2001 From: David LY <153214527+dlymonkai@users.noreply.github.com> Date: Thu, 24 Oct 2024 21:49:49 +0200 Subject: [PATCH] Fixed parts entities not updated properly when adding a damage (#863) --- packages/common/src/state/actions/createdOneDamage.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/common/src/state/actions/createdOneDamage.ts b/packages/common/src/state/actions/createdOneDamage.ts index 061ef69c5..20c42cd03 100644 --- a/packages/common/src/state/actions/createdOneDamage.ts +++ b/packages/common/src/state/actions/createdOneDamage.ts @@ -62,7 +62,13 @@ export function createdOneDamage(state: MonkState, action: MonkCreatedOneDamageA .filter((v) => v !== undefined) as string[]; const newParts = parts.map((part) => { if (partsRelated.includes(part.id)) { - return { ...part, damages: [...part.damages, payload.damage.id] }; + const damageIds = part.damages.filter( + (damageId) => ![payload.damage.id, payload.localId].includes(damageId), + ); + return { + ...part, + damages: [...damageIds, payload.damage.id], + }; } return part; });