@@ -60,12 +60,12 @@ import CallHandler from 'matrix-react-sdk/lib/CallHandler';
6060
6161import { getVectorConfig } from './getconfig' ;
6262
63+ let lastLocationHashSet = null ;
64+
6365// Disable warnings for now: we use deprecated bluebird functions
6466// and need to migrate, but they spam the console with warnings.
6567Promise . config ( { warnings : false } ) ;
6668
67- let lastLocationHashSet = null ;
68-
6969function initRageshake ( ) {
7070 rageshake . init ( ) . then ( ( ) => {
7171 console . log ( "Initialised rageshake: See https://bugs.chromium.org/p/chromium/issues/detail?id=583193 to fix line numbers on Chrome." ) ;
@@ -179,37 +179,35 @@ function makeRegistrationUrl(params) {
179179}
180180
181181function getConfig ( configJsonFilename ) {
182- let deferred = Promise . defer ( ) ;
183-
184- request (
185- { method : "GET" , url : configJsonFilename } ,
186- ( err , response , body ) => {
187- if ( err || response . status < 200 || response . status >= 300 ) {
188- // Lack of a config isn't an error, we should
189- // just use the defaults.
190- // Also treat a blank config as no config, assuming
191- // the status code is 0, because we don't get 404s
192- // from file: URIs so this is the only way we can
193- // not fail if the file doesn't exist when loading
194- // from a file:// URI.
195- if ( response ) {
196- if ( response . status == 404 || ( response . status == 0 && body == '' ) ) {
197- deferred . resolve ( { } ) ;
182+ return new Promise ( function ( resolve , reject ) {
183+ request (
184+ { method : "GET" , url : configJsonFilename } ,
185+ ( err , response , body ) => {
186+ if ( err || response . status < 200 || response . status >= 300 ) {
187+ // Lack of a config isn't an error, we should
188+ // just use the defaults.
189+ // Also treat a blank config as no config, assuming
190+ // the status code is 0, because we don't get 404s
191+ // from file: URIs so this is the only way we can
192+ // not fail if the file doesn't exist when loading
193+ // from a file:// URI.
194+ if ( response ) {
195+ if ( response . status == 404 || ( response . status == 0 && body == '' ) ) {
196+ resolve ( { } ) ;
197+ }
198198 }
199+ reject ( { err : err , response : response } ) ;
200+ return ;
199201 }
200- deferred . reject ( { err : err , response : response } ) ;
201- return ;
202- }
203-
204- // We parse the JSON ourselves rather than use the JSON
205- // parameter, since this throws a parse error on empty
206- // which breaks if there's no config.json and we're
207- // loading from the filesystem (see above).
208- deferred . resolve ( JSON . parse ( body ) ) ;
209- }
210- ) ;
211202
212- return deferred . promise ;
203+ // We parse the JSON ourselves rather than use the JSON
204+ // parameter, since this throws a parse error on empty
205+ // which breaks if there's no config.json and we're
206+ // loading from the filesystem (see above).
207+ resolve ( JSON . parse ( body ) ) ;
208+ } ,
209+ ) ;
210+ } ) ;
213211}
214212
215213function onTokenLoginCompleted ( ) {
0 commit comments