From 7d8d6c7a450a648be1c2898a7fdc554e87046270 Mon Sep 17 00:00:00 2001 From: lenhanphung <44486647+lenhanphung@users.noreply.github.com> Date: Mon, 2 Feb 2026 21:38:26 +0700 Subject: [PATCH] #488 fix 401 infinite loading loop (#493) --- src/features/Calendars/CalendarSlice.ts | 2 +- src/features/User/userSlice.ts | 2 +- src/utils/apiUtils.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/features/Calendars/CalendarSlice.ts b/src/features/Calendars/CalendarSlice.ts index 83b32fb..403bd1c 100644 --- a/src/features/Calendars/CalendarSlice.ts +++ b/src/features/Calendars/CalendarSlice.ts @@ -380,8 +380,8 @@ const CalendarSlice = createSlice({ }) // Rejected cases .addCase(getCalendarsListAsync.rejected, (state, action) => { + state.pending = false; if (action.payload?.status !== 401) { - state.pending = false; state.error = action.payload?.message || action.error.message || diff --git a/src/features/User/userSlice.ts b/src/features/User/userSlice.ts index f1c0038..6d72ca2 100644 --- a/src/features/User/userSlice.ts +++ b/src/features/User/userSlice.ts @@ -179,8 +179,8 @@ export const userSlice = createSlice({ state.loading = true; }) .addCase(getOpenPaasUserDataAsync.rejected, (state, action) => { + state.loading = false; if (action.payload?.status !== 401) { - state.loading = false; state.error = action.payload?.message || "Failed to fetch user information"; } diff --git a/src/utils/apiUtils.ts b/src/utils/apiUtils.ts index 7b39618..aef517c 100644 --- a/src/utils/apiUtils.ts +++ b/src/utils/apiUtils.ts @@ -49,7 +49,7 @@ export const api = ky.extend({ if (response.status === 401) { // Check if we're already on login flow to prevent redirect loop const currentPath = window.location.pathname; - if (currentPath === "/" || currentPath === "/callback") { + if (currentPath === "/callback") { return response; }