Prevent the content from rerendering when it doesn't get any changes, allowing in-progress edits (closes #31)
This commit is contained in:
parent
ec5f2feb7e
commit
174aceeb91
2 changed files with 34 additions and 1 deletions
|
|
@ -14,4 +14,13 @@ export class AttributeOnlyPlayerSheet extends PlayerSheet {
|
||||||
return parts;
|
return parts;
|
||||||
};
|
};
|
||||||
// #endregion Options
|
// #endregion Options
|
||||||
|
|
||||||
|
// #region Lifecycle
|
||||||
|
_configureRenderOptions(options) {
|
||||||
|
super._configureRenderOptions(options);
|
||||||
|
|
||||||
|
// don't attempt to rerender the content
|
||||||
|
options.parts = options.parts?.filter(partID => partID !== `content`);
|
||||||
|
};
|
||||||
|
// #endregion Lifecycle
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,16 @@ import { TAFDocumentSheetConfig } from "./TAFDocumentSheetConfig.mjs";
|
||||||
|
|
||||||
const { HandlebarsApplicationMixin } = foundry.applications.api;
|
const { HandlebarsApplicationMixin } = foundry.applications.api;
|
||||||
const { ActorSheetV2 } = foundry.applications.sheets;
|
const { ActorSheetV2 } = foundry.applications.sheets;
|
||||||
const { getProperty } = foundry.utils;
|
const { getProperty, hasProperty } = foundry.utils;
|
||||||
|
|
||||||
|
const propertyToParts = {
|
||||||
|
"name": [`header`],
|
||||||
|
"img": [`header`],
|
||||||
|
"system.attr": [`attributes`],
|
||||||
|
"system.attr.value": [`attributes`, `content`],
|
||||||
|
"system.attr.max": [`attributes`, `content`],
|
||||||
|
"system.content": [`content`],
|
||||||
|
};
|
||||||
|
|
||||||
export class PlayerSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
|
export class PlayerSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
|
||||||
|
|
||||||
|
|
@ -95,6 +104,21 @@ export class PlayerSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
|
||||||
return controls;
|
return controls;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_configureRenderOptions(options) {
|
||||||
|
// Only rerender the parts of the app that got changed
|
||||||
|
if (options.renderContext === `updateActor`) {
|
||||||
|
const parts = new Set();
|
||||||
|
for (const property in propertyToParts) {
|
||||||
|
if (hasProperty(options.renderData, property)) {
|
||||||
|
propertyToParts[property].forEach(partID => parts.add(partID));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
options.parts = options.parts?.filter(part => !parts.has(part)) ?? Array.from(parts);
|
||||||
|
};
|
||||||
|
|
||||||
|
super._configureRenderOptions(options);
|
||||||
|
};
|
||||||
|
|
||||||
async close() {
|
async close() {
|
||||||
this.#attributeManager?.close();
|
this.#attributeManager?.close();
|
||||||
this.#attributeManager = null;
|
this.#attributeManager = null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue