refactor: stabilize calendar loading effects and menubar redirect

- Memoize calendar range strings and stabilize effect deps
- Guard updateDarkColor to avoid dispatch loops
- Add resilient cache-clear handling with refs
- Memoize calendar/temp ids to prevent rerenders
- Update event handler hooks with missing deps
- Add guards and dependency fixes across Calendar effects
This commit is contained in:
lenhanphung
2025-11-07 16:42:06 +07:00
committed by Benoit TELLIER
parent 990e290066
commit ffe204d60b
13 changed files with 650 additions and 163 deletions
+11 -11
View File
@@ -40,8 +40,16 @@ interface RejectedError {
export const getCalendarsListAsync = createAsyncThunk<
{ importedCalendars: Record<string, Calendars>; errors: string }, // Return type
void, // Arg type
{ rejectValue: RejectedError } // ThunkAPI config
>("calendars/getCalendars", async (_, { rejectWithValue }) => {
{ rejectValue: RejectedError; state: any } // ThunkAPI config
>("calendars/getCalendars", async (_, { rejectWithValue, getState }) => {
const state = getState() as any;
if (Object.keys(state.calendars.list).length > 0) {
return {
importedCalendars: state.calendars.list,
errors: "",
};
}
try {
const importedCalendars: Record<string, Calendars> = {};
const user = (await getOpenPaasUser()) as Record<string, string>;
@@ -106,15 +114,7 @@ export const getCalendarsListAsync = createAsyncThunk<
}
normalizedCalendars.forEach(
({
cal,
description,
delegated,
link,
id,
ownerId,
visibility,
}) => {
({ cal, description, delegated, link, id, ownerId, visibility }) => {
const ownerData = ownerDataMap.get(ownerId) || {
firstname: "",
lastname: "Unknown User",