Files
ThreadNet-Web/apps/web/src/settings/controllers/FontSizeController.ts
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
1.4 KiB
TypeScript
Raw Normal View History

2020-04-14 16:18:57 +01:00
/*
2024-09-09 14:57:16 +01:00
Copyright 2024 New Vector Ltd.
2020-04-14 16:18:57 +01:00
Copyright 2020 The Matrix.org Foundation C.I.C.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
2024-09-09 14:57:16 +01:00
Please see LICENSE files in the repository root for full details.
2020-04-14 16:18:57 +01:00
*/
import SettingController from "./SettingController";
2020-05-20 14:44:56 +01:00
import dis from "../../dispatcher/dispatcher";
2025-02-05 13:25:06 +00:00
import { type UpdateFontSizeDeltaPayload } from "../../dispatcher/payloads/UpdateFontSizeDeltaPayload";
2020-06-15 15:33:52 +01:00
import { Action } from "../../dispatcher/actions";
2020-07-30 08:49:42 -06:00
import { SettingLevel } from "../SettingLevel";
2020-04-14 16:18:57 +01:00
export default class FontSizeController extends SettingController {
public constructor() {
2020-04-16 11:56:43 +01:00
super();
2020-04-14 16:18:57 +01:00
}
public onChange(level: SettingLevel, roomId: string, newValue: any): void {
2023-06-29 11:30:25 +01:00
// In a distant past, `baseFontSize` was set on the account and config
// level. This can be accessed only after the initial sync. If we end up
// discovering that a logged in user has this kind of setting, we want to
// trigger another migration of the base font size.
if (level === SettingLevel.ACCOUNT || level === SettingLevel.CONFIG) {
dis.fire(Action.MigrateBaseFontSize);
} else if (newValue !== "") {
// Dispatch font size change so that everything open responds to the change.
dis.dispatch<UpdateFontSizeDeltaPayload>({
action: Action.UpdateFontSizeDelta,
delta: newValue,
2023-06-29 11:30:25 +01:00
});
}
2020-04-14 16:18:57 +01:00
}
}