Refactor to bring the nuxt loading bar code out of the strategies

This commit is contained in:
Andrew Bastin
2020-01-16 01:25:43 -05:00
parent 2faf675c0a
commit 4b48d8a8c8
3 changed files with 9 additions and 4 deletions

View File

@@ -1,12 +1,19 @@
import AxiosStrategy from "./strategies/AxiosStrategy"; import AxiosStrategy from "./strategies/AxiosStrategy";
import ProxyStrategy from "./strategies/ProxyStrategy"; import ProxyStrategy from "./strategies/ProxyStrategy";
import FirefoxStrategy from "./strategies/FirefoxStrategy";
const runAppropriateStrategy = (req, store) => {
const sendNetworkRequest = (req, store) => {
if (store.state.postwoman.settings.PROXY_ENABLED) { if (store.state.postwoman.settings.PROXY_ENABLED) {
return ProxyStrategy(req, store); return ProxyStrategy(req, store);
} }
return AxiosStrategy(req, store); return AxiosStrategy(req, store);
}; }
const sendNetworkRequest = (req, store) =>
runAppropriateStrategy(req, store)
.finally(() => window.$nuxt.$loading.finish());
export { sendNetworkRequest }; export { sendNetworkRequest };

View File

@@ -2,7 +2,6 @@ import axios from "axios";
const axiosStrategy = async (req, _store) => { const axiosStrategy = async (req, _store) => {
const res = await axios(req); const res = await axios(req);
window.$nuxt.$loading.finish();
return res; return res;
}; };

View File

@@ -6,7 +6,6 @@ const proxyStrategy = async (req, store) => {
"https://postwoman.apollotv.xyz/", "https://postwoman.apollotv.xyz/",
req req
); );
window.$nuxt.$loading.finish();
return data; return data;
}; };