Refactor to bring the nuxt loading bar code out of the strategies
This commit is contained in:
@@ -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 };
|
||||||
|
|||||||
@@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user