Updated strategy identification to consider extensions toggle
This commit is contained in:
@@ -2,16 +2,25 @@ 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) => {
|
||||||
// Chrome Provides a chrome object for scripts to access
|
if (isExtensionsAllowed(store)) {
|
||||||
// Check its availability to say whether you are in Google Chrome
|
// Chrome Provides a chrome object for scripts to access
|
||||||
if (window.chrome && hasChromeExtensionInstalled()) {
|
// Check its availability to say whether you are in Google Chrome
|
||||||
return ChromeStrategy(req, store);
|
if (window.chrome && hasChromeExtensionInstalled()) {
|
||||||
}
|
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
|
// The firefox plugin injects a function to send requests through it
|
||||||
if (window.firefoxExtSendRequest) {
|
// If that is available, then we can use the FirefoxStrategy
|
||||||
return FirefoxStrategy(req, store);
|
if (window.firefoxExtSendRequest) {
|
||||||
|
return FirefoxStrategy(req, store);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return AxiosStrategy(req, store);
|
return AxiosStrategy(req, store);
|
||||||
|
|||||||
Reference in New Issue
Block a user