Skip to content

Commit

Permalink
fix(manager): support v12 async actor link creation
Browse files Browse the repository at this point in the history
Additionally, more fully fake the regex match by building out a complete
string. This may help avoid crashes when using other modules.
  • Loading branch information
cirrahn committed Sep 16, 2024
1 parent cfc0bfb commit 5e55462
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions scripts/effectManager/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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]),
Expand Down Expand Up @@ -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
]);
Expand Down

0 comments on commit 5e55462

Please sign in to comment.