fix: validate event start field when fetching calendar events
This commit is contained in:
@@ -615,7 +615,7 @@ export default function CalendarPage() {
|
||||
|
||||
const visibleEvents = useMemo(() =>
|
||||
events.filter((e) => {
|
||||
if (!e.calendarIds) return false;
|
||||
if (!e.start || !e.calendarIds) return false;
|
||||
const calIds = Object.keys(e.calendarIds);
|
||||
return calIds.some((id) => selectedCalendarIds.includes(id));
|
||||
}),
|
||||
|
||||
@@ -110,10 +110,12 @@ export const useCalendarStore = create<CalendarStore>()(
|
||||
fetchEvents: async (client, start, end) => {
|
||||
set({ isLoadingEvents: true, error: null });
|
||||
try {
|
||||
const events = await client.queryAllCalendarEvents({
|
||||
const rawEvents = await client.queryAllCalendarEvents({
|
||||
after: start,
|
||||
before: end,
|
||||
});
|
||||
// Filter out malformed events missing required 'start' field
|
||||
const events = rawEvents.filter(e => typeof e.start === 'string' && e.start);
|
||||
set({ events, isLoadingEvents: false, dateRange: { start, end } });
|
||||
} catch (error) {
|
||||
debug.error('Failed to fetch events:', error);
|
||||
|
||||
Reference in New Issue
Block a user