Skip to content

Commit 6bf0341

Browse files
committed
Let the user's homeserver config override the build config
Specifically for the desktop app to prevent the warning about too many homeservers defined.
1 parent 515db51 commit 6bf0341

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎electron_app/src/electron-main.js‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ try {
7777
try {
7878
// Load local config and use it to override values from the one baked with the build
7979
const localConfig = require(path.join(app.getPath('userData'), 'config.json'));
80+
81+
// If the local config has a homeserver defined, don't use the homeserver from the build
82+
// config. This is to avoid a problem where Riot thinks there are multiple homeservers
83+
// defined, and panics as a result.
84+
const homeserverProps = ['default_is_url', 'default_hs_url', 'default_server_name', 'default_server_config'];
85+
if (Object.keys(localConfig).find(k => homeserverProps.includes(k))) {
86+
// Rip out all the homeserver options from the vector config
87+
vectorConfig = Object.keys(vectorConfig)
88+
.filter(k => !homeserverProps.includes(k))
89+
.reduce((obj, key) => {obj[key] = vectorConfig[key]; return obj;}, {});
90+
}
91+
8092
vectorConfig = Object.assign(vectorConfig, localConfig);
8193
} catch (e) {
8294
// Could not load local config, this is expected in most cases.

0 commit comments

Comments
 (0)