Skip to content

Commit 2020746

Browse files
committed
fix(progress): add correct eviction key
1 parent e1d3d40 commit 2020746

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/utils/trakt-service.utils.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type BaseInit, getCachedFunction, type TypedResponse } from '@dvcol/base-http-client';
1+
import { type BaseInit, ExactMatchRegex, getCachedFunction, type TypedResponse } from '@dvcol/base-http-client';
22
import { CacheRetention } from '@dvcol/common-utils/common/cache';
33

44
import { getJsonWriter } from '@dvcol/common-utils/common/save';
@@ -89,6 +89,7 @@ export const getSessionUser = async (): Promise<string | undefined> => {
8989
export const getCachedProgressEndpoint = (cache: CacheStore<TraktApiResponse>) => {
9090
const origin = chromeRuntimeId ? undefined : `${WebConfig.CorsProxy}/${WebConfig.CorsPrefix.Trakt}`;
9191
const url: string = ExternaLinks.trakt.onDeck(origin);
92+
const template = { method: 'GET', url };
9293
const baseInit: BaseInit = { credentials: 'include' };
9394
return getCachedFunction(
9495
// @ts-expect-error -- CancellablePromise extends promise
@@ -110,11 +111,12 @@ export const getCachedProgressEndpoint = (cache: CacheStore<TraktApiResponse>) =
110111
retention: CacheRetention.Hour * 2,
111112
key: (param, init) => {
112113
return JSON.stringify({
113-
template: { method: 'GET', url },
114+
template,
114115
param,
115116
init: { ...baseInit, ...init },
116117
});
117118
},
119+
evictionKey: `{"template":${JSON.stringify(template).replace(ExactMatchRegex, '\\$&')}`,
118120
},
119121
);
120122
};

0 commit comments

Comments
 (0)