forked from matrix/element-web
Merge pull request #1612 from vector-im/dbkr/optional_config
Make the config optional
This commit is contained in:
commit
c4b7571c45
|
@ -119,9 +119,7 @@ module.exports = React.createClass({
|
||||||
var emailPusherPromise;
|
var emailPusherPromise;
|
||||||
if (event.target.checked) {
|
if (event.target.checked) {
|
||||||
var data = {}
|
var data = {}
|
||||||
if (this.props.brand) {
|
data['brand'] = this.props.brand || 'Vector';
|
||||||
data['brand'] = this.props.brand;
|
|
||||||
}
|
|
||||||
emailPusherPromise = UserSettingsStore.addEmailPusher(address, data);
|
emailPusherPromise = UserSettingsStore.addEmailPusher(address, data);
|
||||||
} else {
|
} else {
|
||||||
var emailPusher = UserSettingsStore.getEmailPusher(this.state.pushers, address);
|
var emailPusher = UserSettingsStore.getEmailPusher(this.state.pushers, address);
|
||||||
|
|
|
@ -112,6 +112,8 @@ function parseQs(location) {
|
||||||
// Here, we do some crude URL analysis to allow
|
// Here, we do some crude URL analysis to allow
|
||||||
// deep-linking.
|
// deep-linking.
|
||||||
function routeUrl(location) {
|
function routeUrl(location) {
|
||||||
|
if (!window.matrixChat) return;
|
||||||
|
|
||||||
console.log("Routing URL "+window.location);
|
console.log("Routing URL "+window.location);
|
||||||
var params = parseQs(location);
|
var params = parseQs(location);
|
||||||
var loginToken = params.loginToken;
|
var loginToken = params.loginToken;
|
||||||
|
@ -189,7 +191,8 @@ function getConfig() {
|
||||||
{ method: "GET", url: "config.json", json: true },
|
{ method: "GET", url: "config.json", json: true },
|
||||||
(err, response, body) => {
|
(err, response, body) => {
|
||||||
if (err || response.status < 200 || response.status >= 300) {
|
if (err || response.status < 200 || response.status >= 300) {
|
||||||
throw "failed to load config.json";
|
deferred.reject({err: err, response: response});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
deferred.resolve(body);
|
deferred.resolve(body);
|
||||||
|
@ -213,10 +216,26 @@ async function loadApp() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let configJson = await getConfig();
|
let configJson;
|
||||||
|
let configError;
|
||||||
|
try {
|
||||||
|
configJson = await getConfig();
|
||||||
|
} catch (e) {
|
||||||
|
// On 404 errors, carry on without a config,
|
||||||
|
// but on other errors, fail, otherwise it will
|
||||||
|
// lead to subtle errors where the app runs with
|
||||||
|
// the default config if it fails to fetch config.json.
|
||||||
|
if (e.response.status != 404) {
|
||||||
|
configError = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log("Vector starting at "+window.location);
|
console.log("Vector starting at "+window.location);
|
||||||
if (validBrowser) {
|
if (configError) {
|
||||||
|
window.matrixChat = ReactDOM.render(<div className="error">
|
||||||
|
Unable to load config file: please refresh the page to try again.
|
||||||
|
</div>, document.getElementById('matrixchat'));
|
||||||
|
} else if (validBrowser) {
|
||||||
var MatrixChat = sdk.getComponent('structures.MatrixChat');
|
var MatrixChat = sdk.getComponent('structures.MatrixChat');
|
||||||
var fragParts = parseQsFromFragment(window.location);
|
var fragParts = parseQsFromFragment(window.location);
|
||||||
window.matrixChat = ReactDOM.render(
|
window.matrixChat = ReactDOM.render(
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
../config.json
|
|
Loading…
Reference in New Issue