Finish config conversion

This commit is contained in:
N-Pex 2025-07-07 11:23:11 +02:00
parent eb58f77162
commit 4e755ace36
2 changed files with 13 additions and 6 deletions

View file

@ -1,6 +1,8 @@
import * as defaultConfig from "@/assets/config.json";
export class Config {
// Configuration file entries
//
appName: string = "";
appNames: { [key: string]: string } = {};
languageSupportEmail: string = "";
@ -11,6 +13,7 @@ export class Config {
defaultMatrixDomainPart: string = "";
identityServer?: string;
registrationToken?: string;
userIdPrefix?: string;
accentColor?: string;
logo?: string;
analytics: { type?: string; enabled: boolean; config?: any }[] = [];
@ -27,6 +30,9 @@ export class Config {
shortCodeStickers?: { packs: { name: string; stickers: string[] }[] };
roomTypes: ("group_chat" | "channel" | "file_drop")[] = ["group_chat", "channel", "file_drop"];
// Class implementation
//
_loaded: boolean;
_loadPromise: Promise<Config> | undefined;
@ -57,9 +63,10 @@ export class Config {
fromJson = (json: { [key: string]: any }) => {
for (const key of Object.keys(json)) {
if (!Object.hasOwn(this, key)) {
console.error("NO SUCH CONFIG VALUE", key);
console.warn("Invalid config value", key);
} else {
(this as any)[key] = json[key];
}
(this as any)[key] = json[key];
}
};