From a67dac23cf548401d1e00aad4d2642a0cfa9ea43 Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Tue, 22 May 2018 08:41:22 -0400 Subject: [PATCH] Fixes related to offline startup. Fixed incorrect function name for local distro index loading. Fixed mojang tooltip not showing statuses when offline. Added timeout of 2500ms to news loading, remote distro index retrieval, and mojang status loading. Updates async to fix lodash vulnerability. --- app/assets/js/assetguard.js | 6 +- app/assets/js/mojang.js | 9 ++- app/assets/js/preloader.js | 2 +- app/assets/js/scripts/landing.js | 102 ++++++++++++++++++------------- package-lock.json | 14 ++--- package.json | 2 +- 6 files changed, 79 insertions(+), 56 deletions(-) diff --git a/app/assets/js/assetguard.js b/app/assets/js/assetguard.js index ca55089..60a9482 100644 --- a/app/assets/js/assetguard.js +++ b/app/assets/js/assetguard.js @@ -382,8 +382,12 @@ class AssetGuard extends EventEmitter { static refreshDistributionDataRemote(launcherPath){ return new Promise((resolve, reject) => { const distroURL = 'http://mc.westeroscraft.com/WesterosCraftLauncher/westeroscraft.json' + const opts = { + url: distroURL, + timeout: 2500 + } const distroDest = path.join(launcherPath, 'westeroscraft.json') - request(distroURL, (error, resp, body) => { + request(opts, (error, resp, body) => { if(!error){ distributionData = JSON.parse(body) diff --git a/app/assets/js/mojang.js b/app/assets/js/mojang.js index 4ca9faf..486f2df 100644 --- a/app/assets/js/mojang.js +++ b/app/assets/js/mojang.js @@ -89,14 +89,19 @@ exports.status = function(){ return new Promise((resolve, reject) => { request.get('https://status.mojang.com/check', { - json: true + json: true, + timeout: 2500 }, function(error, response, body){ if(error || response.statusCode !== 200){ console.warn('Unable to retrieve Mojang status.') console.debug('Error while retrieving Mojang statuses:', error) - reject(error || response.statusCode) + //reject(error || response.statusCode) + for(let i=0; i { + AssetGuard.refreshDistributionDataLocal(ConfigManager.getLauncherDirectory()).then((data) => { console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Successfully loaded an older version of the distribution index.') onDistroLoad(data) diff --git a/app/assets/js/scripts/landing.js b/app/assets/js/scripts/landing.js index ccc897c..3ad6edc 100644 --- a/app/assets/js/scripts/landing.js +++ b/app/assets/js/scripts/landing.js @@ -149,6 +149,7 @@ const refreshMojangStatuses = async function(){ try { const statuses = await Mojang.status() greenCount = 0 + greyCount = 0 for(let i=0; i { - const items = $(data).find('item') - const articles = [] + $.ajax( + { + url: newsFeed, + success: (data) => { + const items = $(data).find('item') + const articles = [] - for(let i=0; i { - reject(err) + resolve({ + articles: null + }) }) }) } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 95f2b25..961f0da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -178,11 +178,11 @@ "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" }, "async": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", - "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", + "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==", "requires": { - "lodash": "^4.14.0" + "lodash": "^4.17.10" } }, "async-exit-hook": { @@ -1755,9 +1755,9 @@ } }, "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" }, "lodash.isequal": { "version": "4.5.0", diff --git a/package.json b/package.json index 5583385..a9bc18f 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "homepage": "http://www.westeroscraft.com/", "dependencies": { "adm-zip": "^0.4.11", - "async": "^2.6.0", + "async": "^2.6.1", "discord-rpc": "^3.0.0-beta.10", "ejs": "^2.6.1", "ejs-electron": "^2.0.3",