Apply strictNullChecks
to src/components/views/spaces/*
(#10517)
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
209f5bdf33
commit
c0db739d81
7 changed files with 161 additions and 20 deletions
25
src/theme.ts
25
src/theme.ts
|
@ -16,6 +16,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import { compare } from "matrix-js-sdk/src/utils";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
import { _t } from "./languageHandler";
|
||||
import SettingsStore from "./settings/SettingsStore";
|
||||
|
@ -34,7 +35,8 @@ interface IFontFaces extends Omit<Record<(typeof allowedFontFaceProps)[number],
|
|||
}[];
|
||||
}
|
||||
|
||||
interface ICustomTheme {
|
||||
export type CustomTheme = {
|
||||
name: string;
|
||||
colors: {
|
||||
[key: string]: string;
|
||||
};
|
||||
|
@ -44,7 +46,7 @@ interface ICustomTheme {
|
|||
monospace: string;
|
||||
};
|
||||
is_dark?: boolean; // eslint-disable-line camelcase
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Given a non-high-contrast theme, find the corresponding high-contrast one
|
||||
|
@ -79,11 +81,20 @@ export function enumerateThemes(): { [key: string]: string } {
|
|||
"light-high-contrast": _t("Light high contrast"),
|
||||
"dark": _t("Dark"),
|
||||
};
|
||||
const customThemes = SettingsStore.getValue("custom_themes");
|
||||
const customThemes = SettingsStore.getValue("custom_themes") || [];
|
||||
const customThemeNames: Record<string, string> = {};
|
||||
for (const { name } of customThemes) {
|
||||
customThemeNames[`custom-${name}`] = name;
|
||||
|
||||
try {
|
||||
for (const { name } of customThemes) {
|
||||
customThemeNames[`custom-${name}`] = name;
|
||||
}
|
||||
} catch (err) {
|
||||
logger.warn("Error loading custom themes", {
|
||||
err,
|
||||
customThemes,
|
||||
});
|
||||
}
|
||||
|
||||
return Object.assign({}, customThemeNames, BUILTIN_THEMES);
|
||||
}
|
||||
|
||||
|
@ -166,7 +177,7 @@ function generateCustomFontFaceCSS(faces: IFontFaces[]): string {
|
|||
.join("\n");
|
||||
}
|
||||
|
||||
function setCustomThemeVars(customTheme: ICustomTheme): void {
|
||||
function setCustomThemeVars(customTheme: CustomTheme): void {
|
||||
const { style } = document.body;
|
||||
|
||||
function setCSSColorVariable(name: string, hexColor: string, doPct = true): void {
|
||||
|
@ -209,7 +220,7 @@ function setCustomThemeVars(customTheme: ICustomTheme): void {
|
|||
}
|
||||
}
|
||||
|
||||
export function getCustomTheme(themeName: string): ICustomTheme {
|
||||
export function getCustomTheme(themeName: string): CustomTheme {
|
||||
// set css variables
|
||||
const customThemes = SettingsStore.getValue("custom_themes");
|
||||
if (!customThemes) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue