mirror of https://github.com/vector-im/riot-web
Merge pull request #1292 from MTRNord/promiseDeprecationWarnings
Fix deprecation warning about promise.defer()pull/21833/head
commit
006919cb44
|
@ -231,35 +231,31 @@ export function getCurrentLanguage() {
|
|||
}
|
||||
|
||||
function getLangsJson() {
|
||||
const deferred = Promise.defer();
|
||||
|
||||
request(
|
||||
{ method: "GET", url: i18nFolder + 'languages.json' },
|
||||
(err, response, body) => {
|
||||
if (err || response.status < 200 || response.status >= 300) {
|
||||
deferred.reject({err: err, response: response});
|
||||
return;
|
||||
return new Promise((resolve, reject) => {
|
||||
request(
|
||||
{ method: "GET", url: i18nFolder + 'languages.json' },
|
||||
(err, response, body) => {
|
||||
if (err || response.status < 200 || response.status >= 300) {
|
||||
reject({err: err, response: response});
|
||||
return;
|
||||
}
|
||||
resolve(JSON.parse(body));
|
||||
}
|
||||
deferred.resolve(JSON.parse(body));
|
||||
}
|
||||
);
|
||||
return deferred.promise;
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function getLanguage(langPath) {
|
||||
const deferred = Promise.defer();
|
||||
|
||||
let response_return = {};
|
||||
request(
|
||||
{ method: "GET", url: langPath },
|
||||
(err, response, body) => {
|
||||
if (err || response.status < 200 || response.status >= 300) {
|
||||
deferred.reject({err: err, response: response});
|
||||
return;
|
||||
return new Promise((resolve, reject) => {
|
||||
request(
|
||||
{ method: "GET", url: langPath },
|
||||
(err, response, body) => {
|
||||
if (err || response.status < 200 || response.status >= 300) {
|
||||
reject({err: err, response: response});
|
||||
return;
|
||||
}
|
||||
resolve(JSON.parse(body));
|
||||
}
|
||||
|
||||
deferred.resolve(JSON.parse(body));
|
||||
}
|
||||
);
|
||||
return deferred.promise;
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue