🔧 Fixed some issues with axios cached instance

This commit is contained in:
2022-04-18 12:08:33 -07:00
parent 423aacca2a
commit 253c7357a0
4 changed files with 438 additions and 606 deletions

View File

@@ -31,7 +31,7 @@
"@types/socket.io-client": "^3.0.0", "@types/socket.io-client": "^3.0.0",
"airdcpp-apisocket": "^2.4.4", "airdcpp-apisocket": "^2.4.4",
"array-sort-by": "^1.2.1", "array-sort-by": "^1.2.1",
"axios-cache-interceptor": "^0.8.8", "axios-simple-cache-adapter": "^1.1.0",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"better-docs": "^2.3.2", "better-docs": "^2.3.2",
"calibre-opds": "^1.0.7", "calibre-opds": "^1.0.7",

View File

@@ -1,5 +1,7 @@
import axios from "axios"; import axios from "axios";
import rateLimiter from "axios-rate-limit"; import rateLimiter from "axios-rate-limit";
import { AxiosCacheRequestConfig, createCacheAdapter } from 'axios-simple-cache-adapter';
import qs from "qs"; import qs from "qs";
import { import {
@@ -23,11 +25,8 @@ import {
LIBRARY_SERVICE_BASE_URI, LIBRARY_SERVICE_BASE_URI,
} from "../constants/endpoints"; } from "../constants/endpoints";
import { setupCache } from "axios-cache-interceptor";
// same object, but with updated typings.
const axiosWithCache = setupCache(axios);
const axiosCacheAdapter = createCacheAdapter();
const http = rateLimiter(axios.create(), { const http = rateLimiter(axios.create(), {
maxRequests: 1, maxRequests: 1,
perMilliseconds: 1000, perMilliseconds: 1000,
@@ -39,11 +38,14 @@ export const getWeeklyPullList = (options) => async (dispatch) => {
dispatch({ dispatch({
type: CV_WEEKLY_PULLLIST_CALL_IN_PROGRESS, type: CV_WEEKLY_PULLLIST_CALL_IN_PROGRESS,
}); });
axiosWithCache({
url: `${COMICVINE_SERVICE_URI}/getWeeklyPullList`,
await axios(`${COMICVINE_SERVICE_URI}/getWeeklyPullList`, {
method: "get", method: "get",
params: options, params: options,
}).then((response) => { axiosCacheAdapter,
cache: 1000, // value in MS
} as AxiosCacheRequestConfig).then((response) => {
dispatch({ dispatch({
type: CV_WEEKLY_PULLLIST_FETCHED, type: CV_WEEKLY_PULLLIST_FETCHED,
data: response.data.result, data: response.data.result,

View File

@@ -173,7 +173,6 @@ export const fetchVolumeGroups = () => async (dispatch) => {
url: `${LIBRARY_SERVICE_BASE_URI}/getComicBookGroups`, url: `${LIBRARY_SERVICE_BASE_URI}/getComicBookGroups`,
method: "GET", method: "GET",
}); });
dispatch({ dispatch({
type: IMS_COMIC_BOOK_GROUPS_FETCHED, type: IMS_COMIC_BOOK_GROUPS_FETCHED,
data: response.data, data: response.data,
@@ -265,10 +264,10 @@ export const extractComicArchive =
const imagePath = encodeURI( const imagePath = encodeURI(
`${LIBRARY_SERVICE_HOST}/userdata/expanded/` + `${LIBRARY_SERVICE_HOST}/userdata/expanded/` +
folderName + folderName +
`/` + `/` +
page.name + page.name +
page.extension, page.extension,
); );
comicBookPages.push(imagePath); comicBookPages.push(imagePath);
}); });

1017
yarn.lock

File diff suppressed because it is too large Load Diff