From 8097810784a4e8ffe83a6c78aa92976818850bb5 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 28 Jul 2020 21:49:55 -0600 Subject: [PATCH] Convert DefaultSettingsHandler to TS --- ...ngsHandler.js => DefaultSettingsHandler.ts} | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) rename src/settings/handlers/{DefaultSettingsHandler.js => DefaultSettingsHandler.ts} (72%) diff --git a/src/settings/handlers/DefaultSettingsHandler.js b/src/settings/handlers/DefaultSettingsHandler.ts similarity index 72% rename from src/settings/handlers/DefaultSettingsHandler.js rename to src/settings/handlers/DefaultSettingsHandler.ts index 37bc5b2348..fc1c92c159 100644 --- a/src/settings/handlers/DefaultSettingsHandler.js +++ b/src/settings/handlers/DefaultSettingsHandler.ts @@ -1,6 +1,6 @@ /* Copyright 2017 Travis Ralston -Copyright 2019 New Vector Ltd. +Copyright 2019, 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. @@ -27,29 +27,27 @@ export default class DefaultSettingsHandler extends SettingsHandler { * @param {object} defaults The default setting values, keyed by setting name. * @param {object} invertedDefaults The default inverted setting values, keyed by setting name. */ - constructor(defaults, invertedDefaults) { + constructor(private defaults: any, private invertedDefaults: any) { // TODO: [TS] Appropriate types super(); - this._defaults = defaults; - this._invertedDefaults = invertedDefaults; } - getValue(settingName, roomId) { - let value = this._defaults[settingName]; + public getValue(settingName: string, roomId: string): any { + let value = this.defaults[settingName]; if (value === undefined) { - value = this._invertedDefaults[settingName]; + value = this.invertedDefaults[settingName]; } return value; } - setValue(settingName, roomId, newValue) { + public async setValue(settingName: string, roomId: string, newValue: any): Promise { throw new Error("Cannot set values on the default level handler"); } - canSetValue(settingName, roomId) { + public canSetValue(settingName: string, roomId: string) { return false; } - isSupported() { + public isSupported(): boolean { return true; } }