Fix up any unsupported themes when read from settings
This commit is contained in:
parent
215995de88
commit
df2f520d72
2 changed files with 35 additions and 0 deletions
|
@ -22,6 +22,7 @@ import {
|
||||||
NotificationsEnabledController,
|
NotificationsEnabledController,
|
||||||
} from "./controllers/NotificationControllers";
|
} from "./controllers/NotificationControllers";
|
||||||
import CustomStatusController from "./controllers/CustomStatusController";
|
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
|
// 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'];
|
const LEVELS_ROOM_SETTINGS = ['device', 'room-device', 'room-account', 'account', 'config'];
|
||||||
|
@ -233,6 +234,7 @@ export const SETTINGS = {
|
||||||
"theme": {
|
"theme": {
|
||||||
supportedLevels: ['config'],
|
supportedLevels: ['config'],
|
||||||
default: "dharma",
|
default: "dharma",
|
||||||
|
controller: new ThemeController(),
|
||||||
},
|
},
|
||||||
"webRtcForcePeerToPeer": {
|
"webRtcForcePeerToPeer": {
|
||||||
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG,
|
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG,
|
||||||
|
|
33
src/settings/controllers/ThemeController.js
Normal file
33
src/settings/controllers/ThemeController.js
Normal 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
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue