Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -100,18 +100,17 @@ export default function CalendarApp({
|
||||
const fetchedRangesRef = useRef<Record<string, string>>({});
|
||||
|
||||
// Auto-select personal calendars when first loaded
|
||||
const initialLoadRef = useRef(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
Object.keys(calendars).length > 0 &&
|
||||
userId &&
|
||||
selectedCalendars.length === 0
|
||||
) {
|
||||
if (initialLoadRef.current && Object.keys(calendars).length > 0 && userId) {
|
||||
const personalCalendarIds = Object.keys(calendars).filter(
|
||||
(id) => id.split("/")[0] === userId
|
||||
);
|
||||
setSelectedCalendars(personalCalendarIds);
|
||||
initialLoadRef.current = false;
|
||||
}
|
||||
}, [calendars, userId, selectedCalendars.length]);
|
||||
}, [calendars, userId]);
|
||||
|
||||
const calendarRange = getCalendarRange(selectedDate);
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ export const updateCalsDetails = (
|
||||
});
|
||||
|
||||
if (rangeKey !== previousRangeKey) {
|
||||
selectedCalendars.forEach((id) => {
|
||||
selectedCalendars?.forEach((id) => {
|
||||
dispatch(
|
||||
getCalendarDetailAsync({
|
||||
calId: id,
|
||||
|
||||
Reference in New Issue
Block a user