Fixed action deletion unregistration

This commit is contained in:
WBHarry 2026-01-15 23:23:56 +01:00
parent 0b2241076c
commit 650043f06a

View file

@ -227,6 +227,28 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
const armorData = getScrollTextData(this.parent.parent.system.resources, changed.system.marks, 'armor');
options.scrollingTextData = [armorData];
}
if (changed.system?.actions) {
const triggersToRemove = Object.keys(changed.system.actions).reduce((acc, key) => {
if (!changed.system.actions[key]) {
const strippedKey = key.replace('-=', '');
acc.push(...this.actions.get(strippedKey).triggers.map(x => x.trigger));
}
return acc;
}, []);
game.system.registeredTriggers.unregisterTriggers(triggersToRemove, this.parent.uuid);
if (!(this.parent.parent.token instanceof game.system.api.documents.DhToken)) {
for (const token of this.parent.parent.getActiveTokens()) {
game.system.registeredTriggers.unregisterTriggers(
triggersToRemove,
`${token.document.uuid}.${this.parent.uuid}`
);
}
}
}
}
_onUpdate(changed, options, userId) {