Skip to content

Commit af90728

Browse files
authored
YH-1236: fix refresh (#782)
1 parent 065691d commit af90728

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎src/entities/auth/api/authApi.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ export const authApi = baseApi.injectEndpoints({
2929
method: 'POST',
3030
body,
3131
}),
32-
async onQueryStarted(_, { queryFulfilled, extra }) {
32+
async onQueryStarted(_, { queryFulfilled, extra, dispatch }) {
3333
try {
34+
dispatch(baseApi.util.resetApiState());
3435
const result = await queryFulfilled;
3536
setToLS(LS_ACCESS_TOKEN_KEY, result.data.access_token);
3637
const typedExtra = extra as ExtraArgument;
@@ -93,8 +94,10 @@ export const authApi = baseApi.injectEndpoints({
9394
removeFromLS(LS_ACCESS_TOKEN_KEY);
9495
const typedExtra = extra as ExtraArgument;
9596
typedExtra.navigate(ROUTES.auth.login.page);
96-
dispatch(baseApi.util.resetApiState());
97-
dispatch(clearStore());
97+
setTimeout(() => {
98+
dispatch(baseApi.util.resetApiState());
99+
dispatch(clearStore());
100+
}, 0);
98101
} catch (error) {
99102
// eslint-disable-next-line no-console
100103
console.error(error);

0 commit comments

Comments
 (0)