config: copy missing from default (fix #971)

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/1010/head
Varun Patil 2024-01-05 09:02:29 -08:00
parent a8aa090be1
commit a8a3efd21c
1 changed files with 8 additions and 2 deletions

View File

@ -23,8 +23,7 @@ class StaticConfig {
private async init() {
try {
const res = await axios.get<IConfig>(API.CONFIG_GET());
this.config = res.data as IConfig;
this.config = (await axios.get<IConfig>(API.CONFIG_GET())).data;
} catch (e) {
if (!utils.isNetworkError(e)) {
showError('Failed to load configuration');
@ -57,6 +56,13 @@ class StaticConfig {
this.setLs(key, this.config[key]);
}
// Copy over all missing settings (e.g. local settings)
for (const key in old) {
if (!this.config.hasOwnProperty(key)) {
(this.config as any)[key] = (old as any)[key];
}
}
// Resolve all promises
this.initPromises.forEach((resolve) => resolve());
}