From 763b492e1cd7bbe7db58c312cd838d1beb54a6d8 Mon Sep 17 00:00:00 2001 From: rafaelgssa Date: Sat, 28 Dec 2019 14:09:32 -0300 Subject: [PATCH 1/2] Fix bug that prevents extension from working when access token is expired (closes tegon#125) --- package-lock.json | 2 +- src/class/Request.js | 3 +++ src/modules/background/index.js | 7 ++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1cdabc3..a4794d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "traktflix", - "version": "2.0.10", + "version": "2.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/class/Request.js b/src/class/Request.js index d4f933e..039129f 100644 --- a/src/class/Request.js +++ b/src/class/Request.js @@ -7,6 +7,9 @@ class Request { if (!Shared.isBackgroundPage() && !options.url.match(location.host)) { try { const response = await browser.runtime.sendMessage({ type: `request`, options: JSON.stringify(options) }); + if (response.error) { + throw response; + } options.success(response); } catch (error) { options.error(error.status, error.responseText, error.options); diff --git a/src/modules/background/index.js b/src/modules/background/index.js index adf2819..ab04403 100644 --- a/src/modules/background/index.js +++ b/src/modules/background/index.js @@ -38,7 +38,7 @@ if (chrome && chrome.declarativeContent) { } browser.runtime.onMessage.addListener((request, sender) => { - return new Promise(async (resolve, reject) => { + return new Promise(async resolve => { switch (request.type) { case `getApiDefs`: // noinspection JSIgnoredPromiseFromCall @@ -113,8 +113,9 @@ browser.runtime.onMessage.addListener((request, sender) => { try { const response = await Request.sendAndWait(options); resolve(response); - } catch (error) { - reject(error); + } catch (response) { + response.error = true; + resolve(response); } return; } From e3d87704d10077287692973cdadce1e8e335002d Mon Sep 17 00:00:00 2001 From: rafaelgssa Date: Sat, 28 Dec 2019 14:14:06 -0300 Subject: [PATCH 2/2] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 14a938a..9ca7d8c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "traktflix", - "version": "2.1.0", + "version": "2.1.1", "description": "A Trakt.tv scrobbler for Netflix.", "author": "tegon", "private": true,