From 8f3a72a7f41a20ca2c83069ea2b87fbec04388c3 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Wed, 22 Sep 2021 12:32:18 +0200 Subject: [PATCH] refactor: improve embedded document creation --- src/module/active-effect.ts | 7 ++++--- src/module/actor/sheets/actor-sheet.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/module/active-effect.ts b/src/module/active-effect.ts index 965f9f8..3d3432f 100644 --- a/src/module/active-effect.ts +++ b/src/module/active-effect.ts @@ -92,14 +92,15 @@ export class DS4ActiveEffect extends ActiveEffect { /** * Create a new {@link DS4ActiveEffect} using default data. * - * @param context The context for the creation of the effect, requiring a parent {@link DS4Actor} or {@link DS4Item}. + * @param parent The parent {@link DS4Actor} or {@link DS4Item} of the effect. * @returns A promise that resolved to the created effect or udifined of the creation was prevented. */ - static async createDefault(parent: DS4Actor | DS4Item): Promise { + static async createDefault(parent: DS4Actor | DS4Item): Promise { const createData = { label: getGame().i18n.localize(`DS4.NewEffectLabel`), icon: this.FALLBACK_ICON, }; - return parent.createEmbeddedDocuments("ActiveEffect", [createData]) as Promise; + + return this.create(createData, { parent, pack: parent.pack ?? undefined }); } } diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index 58651f4..5abbd1f 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -141,7 +141,7 @@ export class DS4ActorSheet extends ActorSheet