Fix up any unsupported themes when read from settings

pull/21833/head
J. Ryan Stinnett 2019-02-11 18:10:00 +00:00
parent 215995de88
commit df2f520d72
2 changed files with 35 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import {
NotificationsEnabledController,
} from "./controllers/NotificationControllers";
import CustomStatusController from "./controllers/CustomStatusController";
import ThemeController from './controllers/ThemeController';
// These are just a bunch of helper arrays to avoid copy/pasting a bunch of times
const LEVELS_ROOM_SETTINGS = ['device', 'room-device', 'room-account', 'account', 'config'];
@ -233,6 +234,7 @@ export const SETTINGS = {
"theme": {
supportedLevels: ['config'],
default: "dharma",
controller: new ThemeController(),
},
"webRtcForcePeerToPeer": {
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG,

View File

@ -0,0 +1,33 @@
/*
Copyright 2019 New Vector Ltd
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 SettingController from "./SettingController";
const SUPPORTED_THEMES = [
"dharma",
"dark",
];
export default class ThemeController extends SettingController {
getValueOverride(level, roomId, calculatedValue, calculatedAtLevel) {
// Override in case some no longer supported theme is stored here
if (!SUPPORTED_THEMES.includes(calculatedValue)) {
return "dharma";
}
return null; // no override
}
}