* Separate labs and betas more clearly Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Fix tests Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Capitalize `L` in `Labs` Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Use `labsSections` instead of `SdkConfig.get("show_labs_settings")` Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Link to `betas.md` instead of `labs.md` Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Change labs label back to `Labs` Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Improve labs section copy Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Improve labs flags copy Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * i18n Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Fix cypress tests Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Reduce diff Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Remove empty line Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Fix comment Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Remove margin-bottom for the last child Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Improve code based on review Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Fix ts Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Improve ts Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Fix ts Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Improve code Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Improve TS Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
76 lines
2.9 KiB
TypeScript
76 lines
2.9 KiB
TypeScript
/*
|
|
Copyright 2017 Travis Ralston
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
import { SettingLevel } from "../SettingLevel";
|
|
|
|
/**
|
|
* Represents a controller for individual settings to alter the reading behaviour
|
|
* based upon environmental conditions, or to react to changes and therefore update
|
|
* the working environment.
|
|
*
|
|
* This is not intended to replace the functionality of a SettingsHandler, it is only
|
|
* intended to handle environmental factors for specific settings.
|
|
*/
|
|
export default abstract class SettingController {
|
|
/**
|
|
* Gets the overridden value for the setting, if any. This must return null if the
|
|
* value is not to be overridden, otherwise it must return the new value.
|
|
* @param {string} level The level at which the value was requested at.
|
|
* @param {String} roomId The room ID, may be null.
|
|
* @param {*} calculatedValue The value that the handlers think the setting should be,
|
|
* may be null.
|
|
* @param {SettingLevel} calculatedAtLevel The level for which the calculated value was
|
|
* calculated at. May be null.
|
|
* @return {*} The value that should be used, or null if no override is applicable.
|
|
*/
|
|
public getValueOverride(
|
|
level: SettingLevel,
|
|
roomId: string | null,
|
|
calculatedValue: any,
|
|
calculatedAtLevel: SettingLevel,
|
|
): any {
|
|
return null; // no override
|
|
}
|
|
|
|
/**
|
|
* Called before the setting value has been changed, can abort the change.
|
|
* @param {string} level The level at which the setting has been modified.
|
|
* @param {String} roomId The room ID, may be null.
|
|
* @param {*} newValue The new value for the setting, may be null.
|
|
* @return {boolean} Whether the settings change should be accepted.
|
|
*/
|
|
public async beforeChange(level: SettingLevel, roomId: string, newValue: any): Promise<boolean> {
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Called when the setting value has been changed.
|
|
* @param {string} level The level at which the setting has been modified.
|
|
* @param {String} roomId The room ID, may be null.
|
|
* @param {*} newValue The new value for the setting, may be null.
|
|
*/
|
|
public onChange(level: SettingLevel, roomId: string, newValue: any): void {
|
|
// do nothing by default
|
|
}
|
|
|
|
/**
|
|
* Gets whether the setting has been disabled due to this controller.
|
|
*/
|
|
public get settingDisabled(): boolean {
|
|
return false;
|
|
}
|
|
}
|