mirror of
https://github.com/vector-im/element-call.git
synced 2026-02-26 05:17:04 +00:00
Enable lint rules for Promise handling to discourage misuse of them. (#2607)
* Enable lint rules for Promise handling to discourage misuse of them. Squashed all of Hugh's commits into one. --------- Co-authored-by: Hugh Nimmo-Smith <hughns@element.io>
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
} from "./ConfigOptions";
|
||||
|
||||
export class Config {
|
||||
private static internalInstance: Config;
|
||||
private static internalInstance: Config | undefined;
|
||||
|
||||
public static get(): ConfigOptions {
|
||||
if (!this.internalInstance?.config)
|
||||
@@ -21,23 +21,23 @@ export class Config {
|
||||
return this.internalInstance.config;
|
||||
}
|
||||
|
||||
public static init(): Promise<void> {
|
||||
if (Config.internalInstance?.initPromise) {
|
||||
return Config.internalInstance.initPromise;
|
||||
}
|
||||
Config.internalInstance = new Config();
|
||||
Config.internalInstance.initPromise = new Promise<void>((resolve) => {
|
||||
downloadConfig("../config.json").then((config) => {
|
||||
Config.internalInstance.config = { ...DEFAULT_CONFIG, ...config };
|
||||
resolve();
|
||||
public static async init(): Promise<void> {
|
||||
if (!Config.internalInstance?.initPromise) {
|
||||
const internalInstance = new Config();
|
||||
Config.internalInstance = internalInstance;
|
||||
|
||||
Config.internalInstance.initPromise = downloadConfig(
|
||||
"../config.json",
|
||||
).then((config) => {
|
||||
internalInstance.config = { ...DEFAULT_CONFIG, ...config };
|
||||
});
|
||||
});
|
||||
}
|
||||
return Config.internalInstance.initPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a alternative initializer that does not load anything
|
||||
* from a hosted config file but instead just initializes the conifg using the
|
||||
* from a hosted config file but instead just initializes the config using the
|
||||
* default config.
|
||||
*
|
||||
* It is supposed to only be used in tests. (It is executed in `vite.setup.js`)
|
||||
|
||||
Reference in New Issue
Block a user