mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 00:24:53 +00:00
Deletion fix
This commit is contained in:
@ -9,14 +9,16 @@ import {useFormattedEvents} from "@/components/pages/calendar/useFormattedEvents
|
||||
import {useCalendarControls} from "@/components/pages/calendar/useCalendarControls";
|
||||
import {EventCell} from "@/components/pages/calendar/EventCell";
|
||||
import {isToday} from "date-fns";
|
||||
import { View } from "react-native-ui-lib";
|
||||
import {View} from "react-native-ui-lib";
|
||||
|
||||
interface EventCalendarProps {
|
||||
calendarHeight: number;
|
||||
calendarWidth: number;
|
||||
}
|
||||
|
||||
export const DetailedCalendar: React.FC<EventCalendarProps> = ({calendarHeight, calendarWidth}) => {
|
||||
const MemoizedEventCell = React.memo(EventCell);
|
||||
|
||||
export const DetailedCalendar: React.FC<EventCalendarProps> = React.memo(({calendarHeight, calendarWidth}) => {
|
||||
const {profileData} = useAuthContext();
|
||||
const selectedDate = useAtomValue(selectedDateAtom);
|
||||
const mode = useAtomValue(modeAtom);
|
||||
@ -58,20 +60,21 @@ export const DetailedCalendar: React.FC<EventCalendarProps> = ({calendarHeight,
|
||||
initialDate: selectedDate.toISOString(),
|
||||
}), [selectedDate]);
|
||||
|
||||
const getAttendees = useCallback((event: any) => {
|
||||
return familyMembers?.filter(member => event?.attendees?.includes(member?.uid!)) || [];
|
||||
}, [familyMembers]);
|
||||
|
||||
const renderEvent = useCallback((event: any) => {
|
||||
const attendees = useMemo(() =>
|
||||
familyMembers?.filter(member => event?.attendees?.includes(member?.uid!)) || [],
|
||||
[familyMembers, event.attendees]
|
||||
);
|
||||
const attendees = getAttendees(event);
|
||||
|
||||
return (
|
||||
<EventCell
|
||||
<MemoizedEventCell
|
||||
event={event}
|
||||
onPress={handlePressEvent}
|
||||
attendees={attendees}
|
||||
/>
|
||||
);
|
||||
}, [familyMembers, handlePressEvent]);
|
||||
}, [familyMembers, handlePressEvent, getAttendees]);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedDate && isToday(selectedDate)) {
|
||||
@ -85,12 +88,12 @@ export const DetailedCalendar: React.FC<EventCalendarProps> = ({calendarHeight,
|
||||
{...containerProps}
|
||||
numberOfDays={numberOfDays}
|
||||
calendarWidth={calendarWidth}
|
||||
|
||||
onDateChanged={debouncedOnDateChanged}
|
||||
firstDay={firstDay}
|
||||
events={formattedEvents ?? []}
|
||||
onPressEvent={handlePressEvent}
|
||||
onPressBackground={handlePressCell}
|
||||
|
||||
>
|
||||
<CalendarHeader {...headerProps} />
|
||||
<CalendarBody
|
||||
@ -100,6 +103,8 @@ export const DetailedCalendar: React.FC<EventCalendarProps> = ({calendarHeight,
|
||||
<View marginB-45/>
|
||||
</CalendarContainer>
|
||||
);
|
||||
};
|
||||
});
|
||||
|
||||
DetailedCalendar.displayName = 'DetailedCalendar';
|
||||
|
||||
export default DetailedCalendar;
|
||||
@ -9,7 +9,7 @@ import {
|
||||
modeAtom,
|
||||
} from './atoms';
|
||||
import {MonthCalendar} from "@/components/pages/calendar/MonthCalendar";
|
||||
import {DetailedCalendar} from "@/components/pages/calendar/DetailedCalendar";
|
||||
import DetailedCalendar from "@/components/pages/calendar/DetailedCalendar";
|
||||
|
||||
interface EventCalendarProps {
|
||||
calendarHeight: number;
|
||||
@ -17,7 +17,7 @@ interface EventCalendarProps {
|
||||
}
|
||||
|
||||
export const EventCalendar: React.FC<EventCalendarProps> = React.memo((props) => {
|
||||
const {data: events, isLoading} = useGetEvents();
|
||||
const {isLoading} = useGetEvents();
|
||||
const [mode] = useAtom(modeAtom);
|
||||
const {isSyncing} = useSyncEvents();
|
||||
useCalSync();
|
||||
|
||||
@ -31,7 +31,7 @@ interface FormattedEvent {
|
||||
|
||||
// Precompute time constants
|
||||
const DAY_IN_MS = 24 * 60 * 60 * 1000;
|
||||
const PERIOD_IN_MS = 45 * DAY_IN_MS;
|
||||
const PERIOD_IN_MS = 5 * DAY_IN_MS;
|
||||
const TIME_ZONE = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
|
||||
// Memoize date range calculations
|
||||
|
||||
Reference in New Issue
Block a user