Made sure to load compendium document if it wasn't already (#501)

This commit is contained in:
WBHarry 2025-08-01 16:42:52 +02:00 committed by GitHub
parent ab54edb47c
commit 3014be79ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -126,15 +126,20 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
if (this.actor && this.actor.type === 'character' && this.features) { if (this.actor && this.actor.type === 'character' && this.features) {
for (let f of this.features) { for (let f of this.features) {
const feature = f.item ?? f; const fBase = f.item ?? f;
const createData = foundry.utils.mergeObject(feature.toObject(), { const feature = fBase.system ? fBase : await foundry.utils.fromUuid(fBase.uuid);
system: { const createData = foundry.utils.mergeObject(
originItemType: this.parent.type, feature.toObject(),
originId: data._id, {
identifier: feature.identifier, system: {
subType: feature.item ? feature.type : undefined originItemType: this.parent.type,
} originId: data._id,
}, { inplace: false }); identifier: feature.identifier,
subType: feature.item ? feature.type : undefined
}
},
{ inplace: false }
);
await this.actor.createEmbeddedDocuments('Item', [createData]); await this.actor.createEmbeddedDocuments('Item', [createData]);
} }
} }