From 09a35cf10ad91a386cbf4c8960ec89a68d9093f8 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Thu, 20 Feb 2020 08:52:42 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20Lint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/network.js | 22 ++++++++++++---------- functions/strategies/ChromeStrategy.js | 19 +++++++++---------- functions/strategies/ExtensionStrategy.js | 3 ++- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/functions/network.js b/functions/network.js index 591d8f4d3..22ff13364 100644 --- a/functions/network.js +++ b/functions/network.js @@ -1,16 +1,17 @@ import AxiosStrategy from "./strategies/AxiosStrategy"; import ExtensionStrategy from "./strategies/ExtensionStrategy"; import FirefoxStrategy from "./strategies/FirefoxStrategy"; -import ChromeStrategy, { hasChromeExtensionInstalled } from "./strategies/ChromeStrategy"; +import ChromeStrategy, { + hasChromeExtensionInstalled +} from "./strategies/ChromeStrategy"; -const isExtensionsAllowed = ({ state }) => { - return typeof state.postwoman.settings.EXTENSIONS_ENABLED === 'undefined' - || state.postwoman.settings.EXTENSIONS_ENABLED; -} +const isExtensionsAllowed = ({ state }) => + typeof state.postwoman.settings.EXTENSIONS_ENABLED === "undefined" || + state.postwoman.settings.EXTENSIONS_ENABLED; const runAppropriateStrategy = (req, store) => { if (isExtensionsAllowed(store)) { - if (typeof window.__POSTWOMAN_EXTENSION_HOOK__ !== 'undefined') { + if (typeof window.__POSTWOMAN_EXTENSION_HOOK__ !== "undefined") { return ExtensionStrategy(req, store); } @@ -19,7 +20,7 @@ const runAppropriateStrategy = (req, store) => { // Chrome Provides a chrome object for scripts to access // Check its availability to say whether you are in Google Chrome if (window.chrome && hasChromeExtensionInstalled()) { - return ChromeStrategy(req, store); + return ChromeStrategy(req, store); } // The firefox plugin injects a function to send requests through it // If that is available, then we can use the FirefoxStrategy @@ -29,10 +30,11 @@ const runAppropriateStrategy = (req, store) => { } return AxiosStrategy(req, store); -} +}; const sendNetworkRequest = (req, store) => - runAppropriateStrategy(req, store) - .finally(() => window.$nuxt.$loading.finish()); + runAppropriateStrategy(req, store).finally(() => + window.$nuxt.$loading.finish() + ); export { sendNetworkRequest }; diff --git a/functions/strategies/ChromeStrategy.js b/functions/strategies/ChromeStrategy.js index 1c525e3ed..fe88338cb 100644 --- a/functions/strategies/ChromeStrategy.js +++ b/functions/strategies/ChromeStrategy.js @@ -3,9 +3,8 @@ const EXTENSION_ID = "amknoiejhlmhancpahfcfcfhllgkpbld"; // Check if the Chrome Extension is present // The Chrome extension injects an empty span to help detection. // Also check for the presence of window.chrome object to confirm smooth operations -export const hasChromeExtensionInstalled = () => { - return document.getElementById("chromePWExtensionDetect") !== null; -}; +export const hasChromeExtensionInstalled = () => + document.getElementById("chromePWExtensionDetect") !== null; const chromeWithoutProxy = (req, _store) => new Promise((resolve, reject) => { @@ -17,11 +16,11 @@ const chromeWithoutProxy = (req, _store) => config: req } }, - message => { - if (message.data.error) { - reject(message.data.error); + ({ data }) => { + if (data.error) { + reject(data.error); } else { - resolve(message.data.response); + resolve(data.response); } } ); @@ -43,11 +42,11 @@ const chromeWithProxy = (req, { state }) => } } }, - message => { - if (message.data.error) { + ({ data }) => { + if (data.error) { reject(error); } else { - resolve(message.data.response.data); + resolve(data.response.data); } } ); diff --git a/functions/strategies/ExtensionStrategy.js b/functions/strategies/ExtensionStrategy.js index 3305f0b6e..837498a1d 100644 --- a/functions/strategies/ExtensionStrategy.js +++ b/functions/strategies/ExtensionStrategy.js @@ -1,7 +1,8 @@ const extensionWithProxy = async (req, { state }) => { const { data } = await window.__POSTWOMAN_EXTENSION_HOOK__.sendRequest({ method: "post", - url: state.postwoman.settings.PROXY_URL || "https://postwoman.apollotv.xyz/", + url: + state.postwoman.settings.PROXY_URL || "https://postwoman.apollotv.xyz/", data: req }); return data;