Merge pull request #1292 from MTRNord/promiseDeprecationWarnings

Fix deprecation warning about promise.defer()
pull/21833/head
Luke Barnard 2017-08-24 16:20:48 +01:00 committed by GitHub
commit 006919cb44
1 changed files with 22 additions and 26 deletions

View File

@ -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;
);
});
}