@@ -13,7 +13,7 @@ import { getNextURLFromLinkHeader } from './utils';
1313
1414type AxiosRequestConfigWithAccount = AxiosRequestConfig & { account : Account } ;
1515
16- // const MUTATION_HTTP_METHODS: Set<Method> = new Set(['PATCH', 'PUT', 'DELETE']);
16+ const MUTATION_HTTP_METHODS : Set < Method > = new Set ( [ 'PATCH' , 'PUT' , 'DELETE' ] ) ;
1717
1818const instance = Axios . create ( ) ;
1919const axios = setupCache ( instance , {
@@ -43,21 +43,21 @@ const axios = setupCache(instance, {
4343
4444// Invalidate cache on mutating requests (PATCH, PUT, DELETE)
4545// Only clears cache entries for the same account that made the mutation
46- // axios.interceptors.response.use(
47- // async (response) => {
48- // const method = response.config.method?.toUpperCase() as Method;
49- // const config = response.config as AxiosRequestConfigWithAccount;
50-
51- // if (MUTATION_HTTP_METHODS.has(method) && config.account) {
52- // await clearFullApiCache();
53- // }
54- // return response;
55- // },
56- // (error: Error) => {
57- // // Pass through errors without clearing cache
58- // return Promise.reject(error);
59- // },
60- // );
46+ axios . interceptors . response . use (
47+ async ( response ) => {
48+ const method = response . config . method ?. toUpperCase ( ) as Method ;
49+ const config = response . config as AxiosRequestConfigWithAccount ;
50+
51+ if ( MUTATION_HTTP_METHODS . has ( method ) && config . account ) {
52+ await clearFullApiCache ( ) ;
53+ }
54+ return response ;
55+ } ,
56+ ( error : Error ) => {
57+ // Pass through errors without clearing cache
58+ return Promise . reject ( error ) ;
59+ } ,
60+ ) ;
6161
6262/**
6363 * Perform an unauthenticated API request
@@ -165,9 +165,9 @@ async function getHeaders(token?: Token) {
165165}
166166
167167export async function clearFullApiCache ( ) : Promise < void > {
168- // try {
169- // axios.storage.clear();
170- // } catch (err) {
171- // rendererLogError('clearFullApiCache', 'Failed to clear API cache', err);
172- // }
168+ try {
169+ axios . storage . clear ( ) ;
170+ } catch ( err ) {
171+ rendererLogError ( 'clearFullApiCache' , 'Failed to clear API cache' , err ) ;
172+ }
173173}
0 commit comments