Simplify getting the source name of effects
This commit is contained in:
parent
e39d245aff
commit
4d2a7d1686
6 changed files with 17 additions and 17 deletions
|
@ -21,4 +21,11 @@ export class DS4ActiveEffect extends ActiveEffect {
|
|||
}
|
||||
return super.apply(actor, change);
|
||||
}
|
||||
|
||||
/**
|
||||
* A public wrapper for {@link ActiveEffect#_getSourceName}.
|
||||
*/
|
||||
async getSourceName(): Promise<string> {
|
||||
return this._getSourceName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import { getCanvas, getGame } from "../../helpers";
|
|||
import { DS4Item } from "../../item/item";
|
||||
import { DS4Settings, getDS4Settings } from "../../settings";
|
||||
import notifications from "../../ui/notifications";
|
||||
import { DS4Actor } from "../actor";
|
||||
import { isCheck } from "../actor-data-properties";
|
||||
|
||||
/**
|
||||
|
@ -61,16 +60,10 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
|
|||
}),
|
||||
);
|
||||
|
||||
const enrichedEffectPromises = this.actor.effects.toObject().map(async (effect) => {
|
||||
const originatingDocument = effect.origin !== undefined ? await fromUuid(effect.origin) : undefined;
|
||||
const source =
|
||||
(originatingDocument instanceof DS4Actor || originatingDocument instanceof DS4Item
|
||||
? originatingDocument.name
|
||||
: null) ?? undefined;
|
||||
|
||||
const enrichedEffectPromises = this.actor.effects.map(async (effect) => {
|
||||
return {
|
||||
...effect,
|
||||
source,
|
||||
...effect.toObject(),
|
||||
sourceName: await effect.getSourceName(),
|
||||
};
|
||||
});
|
||||
const enrichedEffects = await Promise.all(enrichedEffectPromises);
|
||||
|
@ -335,5 +328,5 @@ interface DS4ActorSheetData extends ActorSheet.Data<ActorSheet.Options> {
|
|||
type ActiveEffectDataSource = foundry.data.ActiveEffectData["_source"];
|
||||
|
||||
interface EnrichedActiveEffectDataSource extends ActiveEffectDataSource {
|
||||
source?: string;
|
||||
sourceName: string;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue