Fixed so that CompendiumSetting saving refreshes the CompendiumBrowser for all users

This commit is contained in:
WBHarry 2026-02-08 16:03:46 +01:00
parent 1ee581055a
commit ed77ae3c91
3 changed files with 36 additions and 2 deletions

View file

@ -123,6 +123,16 @@ export default class CompendiumBrowserSettings extends HandlebarsApplicationMixi
CONFIG.DH.SETTINGS.gameSettings.CompendiumBrowserSettings,
settings.toObject()
);
this.updated = true;
this.close();
}
static async configure() {
return new Promise(resolve => {
const app = new this();
app.addEventListener('close', () => resolve(app.updated), { once: true });
app.render({ force: true });
});
}
}

View file

@ -1,3 +1,5 @@
import { RefreshType, socketEvent } from '../../systemRegistration/socket.mjs';
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
/**
@ -17,6 +19,13 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
this.config = CONFIG.DH.ITEMBROWSER.compendiumConfig;
this.presets = {};
this.compendiumBrowserTypeKey = 'compendiumBrowserDefault';
this.setupHooks = Hooks.on(socketEvent.Refresh, ({ refreshType }) => {
if (refreshType === RefreshType.CompendiumBrowser) {
this.render({ force: true });
this.loadItems();
}
});
}
/** @inheritDoc */
@ -518,7 +527,16 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
}
static async openSettings() {
new game.system.api.applications.dialogs.CompendiumBrowserSettingsDialog().render({ force: true });
const settingsUpdated = await game.system.api.applications.dialogs.CompendiumBrowserSettingsDialog.configure();
if (settingsUpdated) {
Hooks.callAll(socketEvent.Refresh, { refreshType: RefreshType.CompendiumBrowser });
await game.socket.emit(`system.${CONFIG.DH.id}`, {
action: socketEvent.Refresh,
data: {
refreshType: RefreshType.CompendiumBrowser
}
});
}
}
_createDragProcess() {
@ -580,4 +598,9 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
headerActions.append(button);
}
}
async close(options = {}) {
Hooks.off(socketEvent.Refresh, this.setupHooks);
await super.close(options);
}
}

View file

@ -38,7 +38,8 @@ export const RefreshType = {
Countdown: 'DhCoundownRefresh',
TagTeamRoll: 'DhTagTeamRollRefresh',
EffectsDisplay: 'DhEffectsDisplayRefresh',
Scene: 'DhSceneRefresh'
Scene: 'DhSceneRefresh',
CompendiumBrowser: 'DhCompendiumBrowserRefresh'
};
export const registerSocketHooks = () => {