From 5e554626df6f48df62b60eebe1d091da539922a8 Mon Sep 17 00:00:00 2001 From: cirrahn <9784519+cirrahn@users.noreply.github.com> Date: Mon, 16 Sep 2024 13:10:48 +0100 Subject: [PATCH] fix(manager): support v12 async actor link creation Additionally, more fully fake the regex match by building out a complete string. This may help avoid crashes when using other modules. --- scripts/effectManager/app.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/effectManager/app.js b/scripts/effectManager/app.js index bda7090..409d272 100644 --- a/scripts/effectManager/app.js +++ b/scripts/effectManager/app.js @@ -139,7 +139,7 @@ export class EffectManagerApp extends FormApplication { _getDataCache_lids; /** @override */ - getData(options = {}) { + async getData(options = {}) { const dataModel = this._datamodel.toObject(); const effectCounts = this._getData_getEffectCounts({ dataModel }); @@ -150,12 +150,14 @@ export class EffectManagerApp extends FormApplication { isDuplicate: this._getData_isEffectDuplicate({ dataModel, effect, effectCounts }), })); - const folders = Object.entries(dataModel.folders).map(([id, folder]) => ({ - id, - ...folder, - actorLink: this._getData_getActorLinkHtml({ actorUuid: folder.actorUuid }), - effects: effects.filter(effect => effect.folderId === id), - })); + const folders = await Promise.all( + Object.entries(dataModel.folders).map(async ([id, folder]) => ({ + id, + ...folder, + actorLink: await this._getData_pGetActorLinkHtml({ actorUuid: folder.actorUuid }), + effects: effects.filter(effect => effect.folderId === id), + })), + ); this._getDataCache_macro_choices ||= Object.fromEntries( this.constructor._macroLookup.map(({ name, uuid }) => [uuid, name]), @@ -220,12 +222,12 @@ export class EffectManagerApp extends FormApplication { }; } - _getData_getActorLinkHtml({ actorUuid }) { + async _getData_pGetActorLinkHtml({ actorUuid }) { if (actorUuid == null) return null; // Fake a regex match - const lnk = TextEditor._createContentLink([ - null, // m0, full match + const lnk = await TextEditor._createContentLink([ + `@UUID[${actorUuid}]`, // m0, full match "UUID", // m1, type actorUuid, // m2, target ]);