2019-02-11 18:10:00 +00:00
|
|
|
/*
|
|
|
|
|
Copyright 2019 New Vector Ltd
|
2019-08-11 03:43:34 +01:00
|
|
|
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
|
2019-02-11 18:10:00 +00:00
|
|
|
|
|
|
|
|
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";
|
2019-10-01 15:21:22 +02:00
|
|
|
import {DEFAULT_THEME, enumerateThemes} from "../../theme";
|
2019-02-11 18:10:00 +00:00
|
|
|
|
|
|
|
|
export default class ThemeController extends SettingController {
|
2020-01-31 12:28:14 +00:00
|
|
|
static isLogin = false;
|
|
|
|
|
|
2019-02-11 18:10:00 +00:00
|
|
|
getValueOverride(level, roomId, calculatedValue, calculatedAtLevel) {
|
2019-11-28 13:40:28 -07:00
|
|
|
if (!calculatedValue) return null; // Don't override null themes
|
|
|
|
|
|
2020-07-14 13:56:24 +01:00
|
|
|
if (ThemeController.isLogin) return 'element';
|
2020-01-31 12:28:14 +00:00
|
|
|
|
2019-10-01 15:21:22 +02:00
|
|
|
const themes = enumerateThemes();
|
2019-02-11 18:10:00 +00:00
|
|
|
// Override in case some no longer supported theme is stored here
|
2019-10-01 15:21:22 +02:00
|
|
|
if (!themes[calculatedValue]) {
|
2019-08-12 14:24:12 +01:00
|
|
|
return DEFAULT_THEME;
|
2019-02-11 18:10:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null; // no override
|
|
|
|
|
}
|
|
|
|
|
}
|