Skip to content

Commit

Permalink
Fixed parts entities not updated properly when adding a damage (#863)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlymonkai authored Oct 24, 2024
1 parent b87808a commit bbe3221
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/common/src/state/actions/createdOneDamage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down

0 comments on commit bbe3221

Please sign in to comment.