Appease the linter round 1
Signed-off-by: Travis Ralston <travpc@gmail.com>
This commit is contained in:
parent
23d159e21c
commit
7dda5e9196
9 changed files with 16 additions and 25 deletions
|
@ -46,4 +46,4 @@ export default class AccountSettingHandler extends SettingsHandler {
|
||||||
if (!event || !event.getContent()) return {};
|
if (!event || !event.getContent()) return {};
|
||||||
return event.getContent();
|
return event.getContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,4 +40,4 @@ export default class ConfigSettingsHandler extends SettingsHandler {
|
||||||
isSupported() {
|
isSupported() {
|
||||||
return true; // SdkConfig is always there
|
return true; // SdkConfig is always there
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,4 +46,4 @@ export default class DefaultSettingsHandler extends SettingsHandler {
|
||||||
isSupported() {
|
isSupported() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,4 +87,4 @@ export default class DeviceSettingsHandler extends SettingsHandler {
|
||||||
_writeFeature(featureName, enabled) {
|
_writeFeature(featureName, enabled) {
|
||||||
localStorage.setItem("mx_labs_feature_" + featureName, enabled);
|
localStorage.setItem("mx_labs_feature_" + featureName, enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Promise from 'bluebird';
|
|
||||||
import SettingsHandler from "./SettingsHandler";
|
import SettingsHandler from "./SettingsHandler";
|
||||||
import MatrixClientPeg from '../MatrixClientPeg';
|
import MatrixClientPeg from '../MatrixClientPeg';
|
||||||
|
|
||||||
|
@ -49,4 +48,4 @@ export default class RoomAccountSettingsHandler extends SettingsHandler {
|
||||||
if (!event || !event.getContent()) return {};
|
if (!event || !event.getContent()) return {};
|
||||||
return event.getContent();
|
return event.getContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,4 +50,4 @@ export default class RoomDeviceSettingsHandler extends SettingsHandler {
|
||||||
_getKey(settingName, roomId) {
|
_getKey(settingName, roomId) {
|
||||||
return "mx_setting_" + settingName + "_" + roomId;
|
return "mx_setting_" + settingName + "_" + roomId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,4 +51,4 @@ export default class RoomSettingsHandler extends SettingsHandler {
|
||||||
if (!event || !event.getContent()) return {};
|
if (!event || !event.getContent()) return {};
|
||||||
return event.getContent();
|
return event.getContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,6 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Promise from 'bluebird';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the base class for all level handlers. This class performs no logic
|
* Represents the base class for all level handlers. This class performs no logic
|
||||||
* and should be overridden.
|
* and should be overridden.
|
||||||
|
@ -27,8 +25,7 @@ export default class SettingsHandler {
|
||||||
* applicable to this level and may be ignored by the handler.
|
* applicable to this level and may be ignored by the handler.
|
||||||
* @param {string} settingName The name of the setting.
|
* @param {string} settingName The name of the setting.
|
||||||
* @param {String} roomId The room ID to read from, may be null.
|
* @param {String} roomId The room ID to read from, may be null.
|
||||||
* @return {Promise<object>} Resolves to the setting value. Rejected if the value
|
* @returns {*} The setting value, or null if not found.
|
||||||
* could not be found.
|
|
||||||
*/
|
*/
|
||||||
getValue(settingName, roomId) {
|
getValue(settingName, roomId) {
|
||||||
throw new Error("Operation not possible: getValue was not overridden");
|
throw new Error("Operation not possible: getValue was not overridden");
|
||||||
|
@ -43,7 +40,7 @@ export default class SettingsHandler {
|
||||||
* @param {string} settingName The name of the setting to change.
|
* @param {string} settingName The name of the setting to change.
|
||||||
* @param {String} roomId The room ID to set the value in, may be null.
|
* @param {String} roomId The room ID to set the value in, may be null.
|
||||||
* @param {*} newValue The new value for the setting, may be null.
|
* @param {*} newValue The new value for the setting, may be null.
|
||||||
* @return {Promise} Resolves when the setting has been saved.
|
* @returns {Promise} Resolves when the setting has been saved.
|
||||||
*/
|
*/
|
||||||
setValue(settingName, roomId, newValue) {
|
setValue(settingName, roomId, newValue) {
|
||||||
throw new Error("Operation not possible: setValue was not overridden");
|
throw new Error("Operation not possible: setValue was not overridden");
|
||||||
|
@ -67,4 +64,4 @@ export default class SettingsHandler {
|
||||||
isSupported() {
|
isSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,9 +59,9 @@ const SETTINGS = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convert the above into simpler formats for the handlers
|
// Convert the above into simpler formats for the handlers
|
||||||
let defaultSettings = {};
|
const defaultSettings = {};
|
||||||
let featureNames = [];
|
const featureNames = [];
|
||||||
for (let key of Object.keys(SETTINGS)) {
|
for (const key of Object.keys(SETTINGS)) {
|
||||||
defaultSettings[key] = SETTINGS[key].defaults;
|
defaultSettings[key] = SETTINGS[key].defaults;
|
||||||
if (SETTINGS[key].isFeature) featureNames.push(key);
|
if (SETTINGS[key].isFeature) featureNames.push(key);
|
||||||
}
|
}
|
||||||
|
@ -132,12 +132,7 @@ export default class SettingsStore {
|
||||||
throw new Error("Setting " + settingName + " is not a feature");
|
throw new Error("Setting " + settingName + " is not a feature");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synchronously get the setting value (which should be {enabled: true/false})
|
return SettingsStore.getValue(settingName, roomId);
|
||||||
const value = Promise.coroutine(function* () {
|
|
||||||
return yield SettingsStore.getValue(settingName, roomId);
|
|
||||||
})();
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,7 +144,7 @@ export default class SettingsStore {
|
||||||
*/
|
*/
|
||||||
static getValue(settingName, roomId) {
|
static getValue(settingName, roomId) {
|
||||||
const levelOrder = [
|
const levelOrder = [
|
||||||
'device', 'room-device', 'room-account', 'account', 'room', 'config', 'default'
|
'device', 'room-device', 'room-account', 'account', 'room', 'config', 'default',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (SettingsStore.isFeature(settingName)) {
|
if (SettingsStore.isFeature(settingName)) {
|
||||||
|
@ -161,7 +156,7 @@ export default class SettingsStore {
|
||||||
|
|
||||||
const handlers = SettingsStore._getHandlers(settingName);
|
const handlers = SettingsStore._getHandlers(settingName);
|
||||||
|
|
||||||
for (let level of levelOrder) {
|
for (const level of levelOrder) {
|
||||||
let handler = handlers[level];
|
let handler = handlers[level];
|
||||||
if (!handler) continue;
|
if (!handler) continue;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue