Fixed removal of features/items propagating

This commit is contained in:
WBHarry 2025-07-23 14:59:33 +02:00
parent 30f31e77dd
commit 6a7f19363d
2 changed files with 21 additions and 15 deletions

View file

@ -1318,8 +1318,7 @@ export const itemLinkFeatureTypes = {
class: 'class', class: 'class',
foundation: 'foundation', foundation: 'foundation',
specialization: 'specialization', specialization: 'specialization',
mastery: 'mastery', mastery: 'mastery'
subclass: 'subclass'
}; };
export const itemLinkItemTypes = { export const itemLinkItemTypes = {
@ -1332,6 +1331,7 @@ export const itemLinkItemTypes = {
}; };
export const itemLinkTypes = { export const itemLinkTypes = {
subclass: 'subclass',
...itemLinkFeatureTypes, ...itemLinkFeatureTypes,
...itemLinkItemTypes ...itemLinkItemTypes
}; };

View file

@ -171,18 +171,24 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
); );
} }
// if (this.metadata.isItemLinkable) { if (this.metadata.isItemLinkable) {
// const linkEntries = Object.entries(this.itemLinks); const linkEntries = Object.entries(this.itemLinks);
// for (let [uuid, type] of linkEntries) { for (let [type, uuidList] of linkEntries) {
// const item = await foundry.utils.fromUuid(uuid); for (let uuid of uuidList) {
// const path = CONFIG.DH.ITEM.itemLinkFeatureTypes[type] ? 'system.features' : 'system.linkedItems'; const item = await foundry.utils.fromUuid(uuid);
// await item.update({ const path = CONFIG.DH.ITEM.itemLinkFeatureTypes[type]
// [path]: foundry.utils ? 'system.features'
// .getProperty(item, path) : CONFIG.DH.ITEM.itemLinkItemTypes[type]
// .filter(x => x.uuid !== this.parent.uuid) ? 'system.linkedItems'
// .map(x => x.uuid) : 'system.subclasses';
// }); await item.update({
// } [path]: foundry.utils
// } .getProperty(item, path)
.filter(x => x.uuid !== this.parent.uuid)
.map(x => x.uuid)
});
}
}
}
} }
} }