Update chatSidebarBackground to use the same structure as startingSidebarTab and move init hook into the main entrypoint

This commit is contained in:
Oliver 2025-12-06 23:17:37 -07:00
parent 321a4ab0eb
commit 8ca82c2cc1
3 changed files with 29 additions and 34 deletions

View file

@ -1,15 +1,10 @@
import { __ID } from "../consts.mjs";
import { chatSidebarBackground } from "../settings/chatSidebarBackground.mjs";
import { preventUserConfigOpen } from "../settings/preventUserConfigOpen.mjs";
import { startingSidebarTab } from "../settings/startingSidebarTab.mjs";
import { startSidebarExpanded } from "../settings/startSidebarExpanded.mjs";
Hooks.once(`init`, () => {
console.log(`${__ID} | Initializing`);
chatSidebarBackground.register();
preventUserConfigOpen.register();
startSidebarExpanded.register();
startingSidebarTab();
});

View file

@ -3,3 +3,10 @@ import "./hooks/init.mjs";
import "./hooks/ready.mjs";
import "./hooks/renderSidebar.mjs";
import "./hooks/renderUserConfig.mjs";
import { chatSidebarBackground } from "./settings/chatSidebarBackground.mjs";
import { startingSidebarTab } from "./settings/startingSidebarTab.mjs";
Hooks.once(`init`, () => {
chatSidebarBackground();
startingSidebarTab();
});

View file

@ -1,35 +1,28 @@
import { __ID, inDev } from "../consts.mjs";
import { __ID } from "../consts.mjs";
import { Logger } from "../utils/Logger.mjs";
const key = `chatSidebarBackground`;
const config = {
name: `OFT.setting.${key}.name`,
hint: `OFT.setting.${key}.hint`,
scope: `user`,
type: Boolean,
default: true,
config: true,
requiresReload: false,
onChange: (newValue) => {
if (inDev()) {
console.log(`${__ID} | setting:${key} | Setting to: ${newValue}`);
};
document.body.classList.toggle(`oft-${key}`, newValue);
},
};
export function chatSidebarBackground() {
export const chatSidebarBackground = {
value() {
return game.settings.get(__ID, key);
},
register() {
game.settings.register(__ID, key, config);
// #region Registration
game.settings.register(__ID, key, {
name: `OFT.setting.${key}.name`,
hint: `OFT.setting.${key}.hint`,
scope: `user`,
type: Boolean,
default: true,
config: true,
requiresReload: false,
onChange: (newValue) => {
Logger.debug(`setting:${key} | Setting to ${newValue}`);
document.body.classList.toggle(`oft-${key}`, newValue);
},
});
if (this.value()) {
if (inDev()) {
console.log(`${__ID} | setting:${key} | Adding chat background`);
};
document.body.classList.add(`oft-${key}`);
};
},
if (game.settings.get(__ID, key)) {
Logger.debug(`setting:${key} | Adding chat background`);
document.body.classList.add(`oft-${key}`);
};
// #endregion Registration
};