Skip to content

Commit 6a6118e

Browse files
committed
serve config.json statically instead of bundling it
issue element-hq#1344
1 parent 8fb521c commit 6a6118e

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
},
3434
"dependencies": {
3535
"babel-polyfill": "^6.5.0",
36+
"browser-request": "^0.3.3",
3637
"classnames": "^2.1.2",
3738
"extract-text-webpack-plugin": "^0.9.1",
3839
"filesize": "^3.1.2",

‎src/vector/index.js‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ var ReactDOM = require("react-dom");
4040
var sdk = require("matrix-react-sdk");
4141
sdk.loadSkin(require('../component-index'));
4242
var VectorConferenceHandler = require('../VectorConferenceHandler');
43-
var configJson = require("../../config.json");
4443
var UpdateChecker = require("./updater");
44+
var q = require('q');
45+
var request = require('browser-request');
4546

4647
var qs = require("querystring");
4748

@@ -181,7 +182,24 @@ window.onload = function() {
181182
}
182183
}
183184

184-
function loadApp() {
185+
function getConfig() {
186+
let deferred = q.defer();
187+
188+
request(
189+
{ method: "GET", url: "config.json", json: true },
190+
(err, response, body) => {
191+
if (err || response.status < 200 || response.status >= 300) {
192+
throw "failed to load config.json";
193+
}
194+
195+
deferred.resolve(body);
196+
}
197+
);
198+
199+
return deferred.promise;
200+
}
201+
202+
async function loadApp() {
185203
if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
186204
if (confirm("Vector works much better on iOS as an app. Switch to the app?")) {
187205
window.location = "https://itunes.apple.com/us/app/vector.im/id1083446067";
@@ -194,7 +212,9 @@ function loadApp() {
194212
return;
195213
}
196214
}
197-
215+
216+
let configJson = await getConfig();
217+
198218
console.log("Vector starting at "+window.location);
199219
if (validBrowser) {
200220
var MatrixChat = sdk.getComponent('structures.MatrixChat');

‎vector/config.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../config.json

0 commit comments

Comments
 (0)