Ensure AttributeManager is a singleton per actor

This commit is contained in:
Eldritch-Oliver 2025-09-04 20:21:06 -06:00
parent cd3f076b7d
commit df9a63073a

View file

@ -54,6 +54,12 @@ export class PlayerSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
return controls; return controls;
}; };
async close() {
this.attributeManager?.close();
this.attributeManager = null;
return super.close();
};
// #endregion Lifecycle // #endregion Lifecycle
// #region Data Prep // #region Data Prep
@ -103,10 +109,16 @@ export class PlayerSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
// #endregion Data Prep // #endregion Data Prep
// #region Actions // #region Actions
attributeManager = null;
/** @this {PlayerSheet} */ /** @this {PlayerSheet} */
static async #manageAttributes() { static async #manageAttributes() {
const app = new AttributeManager({ document: this.actor }); this.attributeManager ??= new AttributeManager({ document: this.actor });
await app.render({ force: true }); if (this.attributeManager.rendered) {
await this.attributeManager.bringToFront();
} else {
await this.attributeManager.render({ force: true });
}
}; };
// #endregion Actions // #endregion Actions
}; };