File tree Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -44,3 +44,5 @@ export const {
44
44
useGetOrderTimingQuery,
45
45
useUpdateOrderMutation,
46
46
} = apiSlice ;
47
+
48
+ export const clearApiState = apiSlice . util . resetApiState ;
Original file line number Diff line number Diff line change
1
+ import { clearApiState } from './slice' ;
2
+ import { LOGOUT_SUCCESS , SET_BASE_URL } from '../App/actions' ;
3
+
4
+ export const ApiStateMiddleware = store => next => action => {
5
+ if ( action . type === LOGOUT_SUCCESS || action . type === SET_BASE_URL ) {
6
+ store . dispatch ( clearApiState ( ) ) ;
7
+ }
8
+
9
+ return next ( action ) ;
10
+ } ;
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import { apiSlice } from './api/slice';
22
22
import { setupListeners } from '@reduxjs/toolkit/query' ;
23
23
import { setupListenersReactNative } from './setupListenersReactNative' ;
24
24
import AppStateMiddleware from './middlewares/AppStateMiddleware' ;
25
+ import { ApiStateMiddleware } from './api/stateMiddleware' ;
25
26
26
27
const middlewares = [
27
28
thunk ,
@@ -30,6 +31,7 @@ const middlewares = [
30
31
AppStateMiddleware ,
31
32
HttpMiddleware ,
32
33
apiSlice . middleware ,
34
+ ApiStateMiddleware ,
33
35
PushNotificationMiddleware ,
34
36
CentrifugoMiddleware ,
35
37
SentryMiddleware ,
You can’t perform that action at this time.
0 commit comments