From 4a1ba01f44df7bbe7a7d7812b9c359701edb0e6c Mon Sep 17 00:00:00 2001 From: MTRNord Date: Sun, 13 Aug 2017 00:56:37 +0000 Subject: [PATCH 1/3] fix deprecation warning --- src/languageHandler.js | 47 +++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/src/languageHandler.js b/src/languageHandler.js index e956d4f8bd..54a8596d5d 100644 --- a/src/languageHandler.js +++ b/src/languageHandler.js @@ -231,35 +231,30 @@ 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}); + } + 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) => { + let response_return = {}; + request( + { method: "GET", url: langPath }, + (err, response, body) => { + if (err || response.status < 200 || response.status >= 300) { + reject({err: err, response: response}); + } + resolve(JSON.parse(body)); } - - deferred.resolve(JSON.parse(body)); - } - ); - return deferred.promise; + ); + }); } From 88a0d34c2b9a5c0365c994a438a904470fcf24df Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 24 Aug 2017 15:40:52 +0200 Subject: [PATCH 2/3] Remove unused response_return variable --- src/languageHandler.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/languageHandler.js b/src/languageHandler.js index 54a8596d5d..a5697da1d0 100644 --- a/src/languageHandler.js +++ b/src/languageHandler.js @@ -246,7 +246,6 @@ function getLangsJson() { function getLanguage(langPath) { return new Promise((resolve, reject) => { - let response_return = {}; request( { method: "GET", url: langPath }, (err, response, body) => { From d34ba57adbed79d0a29333326aefcaed7fd13de9 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 24 Aug 2017 16:42:32 +0200 Subject: [PATCH 3/3] Add missing returns --- src/languageHandler.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/languageHandler.js b/src/languageHandler.js index a5697da1d0..a19c796f39 100644 --- a/src/languageHandler.js +++ b/src/languageHandler.js @@ -237,6 +237,7 @@ function getLangsJson() { (err, response, body) => { if (err || response.status < 200 || response.status >= 300) { reject({err: err, response: response}); + return; } resolve(JSON.parse(body)); } @@ -251,6 +252,7 @@ function getLanguage(langPath) { (err, response, body) => { if (err || response.status < 200 || response.status >= 300) { reject({err: err, response: response}); + return; } resolve(JSON.parse(body)); }