From 22be46426c0e82bf39df09e6e96cc5899f662935 Mon Sep 17 00:00:00 2001 From: Quentin DECAUNES Date: Tue, 30 Jul 2019 17:12:28 +0200 Subject: [PATCH] Fixes RYZEN-CONTROLLER-40 - Detect when checkForNewRelease is failing. --- js/methods.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/js/methods.js b/js/methods.js index 0847fa9..6073b43 100644 --- a/js/methods.js +++ b/js/methods.js @@ -497,18 +497,22 @@ function checkForNewRelease() { var request = new XMLHttpRequest(); const version = require('./package.json').version; - request.open('GET', 'https://gitlab.com/api/v4/projects/11046417/releases', true); + try { + request.open('GET', 'https://gitlab.com/api/v4/projects/11046417/releases', true); - request.onload = function() { - if (this.status >= 200 && this.status < 400) { - var resp = JSON.parse(this.response); - if (resp[0].tag_name !== version) { - notification('primary', "A new vesion is available, please check the release tab."); + request.onload = function() { + if (this.status >= 200 && this.status < 400) { + var resp = JSON.parse(this.response); + if (resp[0].tag_name !== version) { + notification('primary', "A new vesion is available, please check the release tab."); + } } - } - }; - - request.send(); + }; + + request.send(); + } catch (error) { + console.log('Unable to check if new release is available.', error); + } } /**