Convert PushToMatrixClientController to TS

pull/21833/head
Travis Ralston 2020-07-28 15:21:10 -06:00
parent 437ccb2421
commit 227b611421
1 changed files with 7 additions and 10 deletions

View File

@ -15,23 +15,20 @@ limitations under the License.
*/
import { MatrixClientPeg } from '../../MatrixClientPeg';
import { SettingLevel } from "../SettingLevel";
import SettingController from "./SettingController";
/**
* When the value changes, call a setter function on the matrix client with the new value
*/
export default class PushToMatrixClientController {
constructor(setter, inverse) {
this._setter = setter;
this._inverse = inverse;
export default class PushToMatrixClientController extends SettingController {
constructor(private setter: Function, private inverse: boolean) {
super();
}
getValueOverride(level, roomId, calculatedValue, calculatedAtLevel) {
return null; // no override
}
onChange(level, roomId, newValue) {
public onChange(level: SettingLevel, roomId: string, newValue: any) {
// XXX does this work? This surely isn't necessarily the effective value,
// but it's what NotificationsEnabledController does...
this._setter.call(MatrixClientPeg.get(), this._inverse ? !newValue : newValue);
this.setter.call(MatrixClientPeg.get(), this.inverse ? !newValue : newValue);
}
}