2020-05-30 22:28:13 +00:00
|
|
|
import AxiosStrategy, { cancelRunningAxiosRequest } from "./strategies/AxiosStrategy"
|
|
|
|
|
import ExtensionStrategy, {
|
|
|
|
|
cancelRunningExtensionRequest,
|
|
|
|
|
hasExtensionInstalled,
|
|
|
|
|
} from "./strategies/ExtensionStrategy"
|
2021-03-23 15:18:14 +00:00
|
|
|
import { settingsStore } from "~/newstore/settings"
|
2020-05-30 22:28:13 +00:00
|
|
|
|
2021-03-23 15:18:14 +00:00
|
|
|
export const cancelRunningRequest = () => {
|
|
|
|
|
if (isExtensionsAllowed() && hasExtensionInstalled()) {
|
2020-05-30 22:28:13 +00:00
|
|
|
cancelRunningExtensionRequest()
|
|
|
|
|
} else {
|
|
|
|
|
cancelRunningAxiosRequest()
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-16 06:25:43 +00:00
|
|
|
|
2021-03-23 15:18:14 +00:00
|
|
|
const isExtensionsAllowed = () => settingsStore.value.EXTENSIONS_ENABLED
|
2020-02-04 18:13:20 +00:00
|
|
|
|
2021-03-23 15:18:14 +00:00
|
|
|
const runAppropriateStrategy = (req) => {
|
|
|
|
|
if (isExtensionsAllowed() && hasExtensionInstalled()) {
|
|
|
|
|
return ExtensionStrategy(req)
|
2020-01-16 06:26:25 +00:00
|
|
|
}
|
2020-01-14 04:47:28 +00:00
|
|
|
|
2021-03-23 15:18:14 +00:00
|
|
|
return AxiosStrategy(req)
|
2020-02-24 18:44:50 +00:00
|
|
|
}
|
2020-01-16 06:25:43 +00:00
|
|
|
|
2021-03-23 15:18:14 +00:00
|
|
|
export const sendNetworkRequest = (req) =>
|
|
|
|
|
runAppropriateStrategy(req).finally(() => window.$nuxt.$loading.finish())
|