Merge pull request #11409 from vector-im/travis/desktop-config

Let the user's homeserver config override the build config
pull/11426/head
Travis Ralston 2019-11-18 10:04:13 -07:00 committed by GitHub
commit efbb66ba4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -77,6 +77,18 @@ try {
try {
// Load local config and use it to override values from the one baked with the build
const localConfig = require(path.join(app.getPath('userData'), 'config.json'));
// If the local config has a homeserver defined, don't use the homeserver from the build
// config. This is to avoid a problem where Riot thinks there are multiple homeservers
// defined, and panics as a result.
const homeserverProps = ['default_is_url', 'default_hs_url', 'default_server_name', 'default_server_config'];
if (Object.keys(localConfig).find(k => homeserverProps.includes(k))) {
// Rip out all the homeserver options from the vector config
vectorConfig = Object.keys(vectorConfig)
.filter(k => !homeserverProps.includes(k))
.reduce((obj, key) => {obj[key] = vectorConfig[key]; return obj;}, {});
}
vectorConfig = Object.assign(vectorConfig, localConfig);
} catch (e) {
// Could not load local config, this is expected in most cases.