Merged with main

This commit is contained in:
WBHarry 2025-11-20 11:13:07 +01:00
commit 30828cd6ee
11 changed files with 341 additions and 54 deletions

View file

@ -82,13 +82,6 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
return frame;
}
/**@inheritdoc */
async _onFirstRender(context, options) {
await super._onFirstRender(context, options);
this.toggleCollapsedPosition(undefined, !ui.sidebar.expanded);
}
/** Returns countdown data filtered by ownership */
#getCountdowns() {
const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
@ -153,14 +146,6 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
: playerOwnership;
}
toggleCollapsedPosition = async (_, collapsed) => {
if (!this.element) return;
this.sidebarCollapsed = collapsed;
if (!collapsed) this.element.classList.add('expanded');
else this.element.classList.remove('expanded');
};
cooldownRefresh = ({ refreshType }) => {
if (refreshType === RefreshType.Countdown) this.render();
};
@ -238,7 +223,6 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
}
setupHooks() {
Hooks.on('collapseSidebar', this.toggleCollapsedPosition.bind());
Hooks.on(socketEvent.Refresh, this.cooldownRefresh.bind());
}
@ -246,7 +230,6 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
/* Opt out of Foundry's standard behavior of closing all application windows marked as UI when Escape is pressed */
if (options.closeKey) return;
Hooks.off('collapseSidebar', this.toggleCollapsedPosition);
Hooks.off(socketEvent.Refresh, this.cooldownRefresh);
return super.close(options);
}
@ -290,5 +273,8 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
async _onRender(context, options) {
await super._onRender(context, options);
this.element.hidden = !game.user.isGM && this.#getCountdowns().length === 0;
if (options?.force) {
document.getElementById('ui-right-column-1')?.appendChild(this.element);
}
}
}