Updated strategy identification to consider extensions toggle

This commit is contained in:
Andrew Bastin
2020-02-04 13:13:20 -05:00
parent f1e752892d
commit 89312347d1

View File

@@ -2,7 +2,15 @@ import AxiosStrategy from "./strategies/AxiosStrategy";
import FirefoxStrategy from "./strategies/FirefoxStrategy"; import FirefoxStrategy from "./strategies/FirefoxStrategy";
import ChromeStrategy, { hasChromeExtensionInstalled } from "./strategies/ChromeStrategy"; import ChromeStrategy, { hasChromeExtensionInstalled } from "./strategies/ChromeStrategy";
const isExtensionsAllowed = ({ state }) => {
console.log(typeof(state.postwoman.settings.EXTENSIONS_ENABLED) === 'undefined'
|| state.postwoman.settings.EXTENSIONS_ENABLED);
return typeof(state.postwoman.settings.EXTENSIONS_ENABLED) === 'undefined'
|| state.postwoman.settings.EXTENSIONS_ENABLED;
}
const runAppropriateStrategy = (req, store) => { const runAppropriateStrategy = (req, store) => {
if (isExtensionsAllowed(store)) {
// Chrome Provides a chrome object for scripts to access // Chrome Provides a chrome object for scripts to access
// Check its availability to say whether you are in Google Chrome // Check its availability to say whether you are in Google Chrome
if (window.chrome && hasChromeExtensionInstalled()) { if (window.chrome && hasChromeExtensionInstalled()) {
@@ -13,6 +21,7 @@ const runAppropriateStrategy = (req, store) => {
if (window.firefoxExtSendRequest) { if (window.firefoxExtSendRequest) {
return FirefoxStrategy(req, store); return FirefoxStrategy(req, store);
} }
}
return AxiosStrategy(req, store); return AxiosStrategy(req, store);
} }