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',
foundation: 'foundation',
specialization: 'specialization',
mastery: 'mastery',
subclass: 'subclass'
mastery: 'mastery'
};
export const itemLinkItemTypes = {
@ -1332,6 +1331,7 @@ export const itemLinkItemTypes = {
};
export const itemLinkTypes = {
subclass: 'subclass',
...itemLinkFeatureTypes,
...itemLinkItemTypes
};

View file

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