Skip to content

Commit c4b7571

Browse files
committed
Merge pull request element-hq#1612 from vector-im/dbkr/optional_config
Make the config optional
2 parents 7894e52 + 4dd477e commit c4b7571

4 files changed

Lines changed: 23 additions & 7 deletions

File tree

‎src/components/views/settings/Notifications.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ module.exports = React.createClass({
119119
var emailPusherPromise;
120120
if (event.target.checked) {
121121
var data = {}
122-
if (this.props.brand) {
123-
data['brand'] = this.props.brand;
124-
}
122+
data['brand'] = this.props.brand || 'Vector';
125123
emailPusherPromise = UserSettingsStore.addEmailPusher(address, data);
126124
} else {
127125
var emailPusher = UserSettingsStore.getEmailPusher(this.state.pushers, address);

‎src/vector/index.js‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ function parseQs(location) {
112112
// Here, we do some crude URL analysis to allow
113113
// deep-linking.
114114
function routeUrl(location) {
115+
if (!window.matrixChat) return;
116+
115117
console.log("Routing URL "+window.location);
116118
var params = parseQs(location);
117119
var loginToken = params.loginToken;
@@ -189,7 +191,8 @@ function getConfig() {
189191
{ method: "GET", url: "config.json", json: true },
190192
(err, response, body) => {
191193
if (err || response.status < 200 || response.status >= 300) {
192-
throw "failed to load config.json";
194+
deferred.reject({err: err, response: response});
195+
return;
193196
}
194197

195198
deferred.resolve(body);
@@ -213,10 +216,26 @@ async function loadApp() {
213216
}
214217
}
215218

216-
let configJson = await getConfig();
219+
let configJson;
220+
let configError;
221+
try {
222+
configJson = await getConfig();
223+
} catch (e) {
224+
// On 404 errors, carry on without a config,
225+
// but on other errors, fail, otherwise it will
226+
// lead to subtle errors where the app runs with
227+
// the default config if it fails to fetch config.json.
228+
if (e.response.status != 404) {
229+
configError = e;
230+
}
231+
}
217232

218233
console.log("Vector starting at "+window.location);
219-
if (validBrowser) {
234+
if (configError) {
235+
window.matrixChat = ReactDOM.render(<div className="error">
236+
Unable to load config file: please refresh the page to try again.
237+
</div>, document.getElementById('matrixchat'));
238+
} else if (validBrowser) {
220239
var MatrixChat = sdk.getComponent('structures.MatrixChat');
221240
var fragParts = parseQsFromFragment(window.location);
222241
window.matrixChat = ReactDOM.render(

‎vector/config.json‎

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)