client: allow changing the max content width option without a frontend reload

This commit is contained in:
Adorian Doran 2025-10-30 00:49:02 +02:00
parent 1ef03b7a77
commit 4063229982
3 changed files with 11 additions and 5 deletions

View File

@ -31,6 +31,7 @@ export default class RootContainer extends FlexContainer<BasicWidget> {
window.visualViewport?.addEventListener("resize", () => this.#onMobileResize());
}
this.#setMaxContentWidth(options.getInt("maxContentWidth") ?? 0);
this.#setMotion(options.is("motionEnabled"));
this.#setShadows(options.is("shadowsEnabled"));
this.#setBackdropEffects(options.is("backdropEffectsEnabled"));
@ -52,7 +53,12 @@ export default class RootContainer extends FlexContainer<BasicWidget> {
if (loadResults.isOptionReloaded("backdropEffectsEnabled")) {
this.#setBackdropEffects(options.is("backdropEffectsEnabled"));
}
if (loadResults.isOptionReloaded("maxContentWidth")) {
this.#setMaxContentWidth(options.getInt("maxContentWidth") ?? 0);
}
}
#onMobileResize() {
const currentViewportHeight = getViewportHeight();
@ -60,6 +66,11 @@ export default class RootContainer extends FlexContainer<BasicWidget> {
this.$widget.toggleClass("virtual-keyboard-opened", isKeyboardOpened);
}
#setMaxContentWidth(width: number) {
width = Math.max(width, 640);
document.body.style.setProperty("--preferred-max-content-width", `${width}px`);
}
#setMotion(enabled: boolean) {
document.body.classList.toggle("motion-disabled", !enabled);
jQuery.fx.off = !enabled;

View File

@ -299,10 +299,6 @@ function MaxContentWidth() {
/>
</FormGroup>
</Column>
<p>
{t("max_content_width.apply_changes_description")} <Button text={t("max_content_width.reload_button")} size="micro" onClick={reloadFrontendApp} />
</p>
</OptionsSection>
)
}

View File

@ -57,7 +57,6 @@ function index(req: Request, res: Response) {
isDev,
isMainWindow: view === "mobile" ? true : !req.query.extraWindow,
isProtectedSessionAvailable: protectedSessionService.isProtectedSessionAvailable(),
maxContentWidth: Math.max(640, parseInt(options.maxContentWidth)),
triliumVersion: packageJson.version,
assetPath,
appPath,