From e2187b1f13be4a15e3fafa6c345507951b42b8a6 Mon Sep 17 00:00:00 2001 From: Clas Wen Date: Thu, 25 Sep 2025 23:36:03 +0800 Subject: [PATCH 1/2] Fix timing issue with event loading and month filtering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed redundant useEffect that was causing a race condition where: 1. Page would load showing all events first 2. Then switch to month-filtered events after a delay The issue was two competing useEffects: - One for month filtering (extractScheduleEventsInRange) - One for loading all events (extractScheduleEvents) Now uses only one useEffect for both initial loading and month filtering, ensuring consistent behavior on page load. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/pages/calendar/Schedule.tsx | 64 --------------------------------- 1 file changed, 64 deletions(-) diff --git a/src/pages/calendar/Schedule.tsx b/src/pages/calendar/Schedule.tsx index e7fc3a3..af70ec3 100644 --- a/src/pages/calendar/Schedule.tsx +++ b/src/pages/calendar/Schedule.tsx @@ -110,62 +110,6 @@ const expandEventOccurrences = ( return occurrences } -const extractScheduleEvents = (icalComp: ICAL.Component): ScheduleEvent[] => { - const vevents = icalComp.getAllSubcomponents("vevent") - const rangeEnd = ICAL.Time.fromDateString("2026-01-01") - const rangeStart = ICAL.Time.fromDateString("2020-01-01") - - // First, collect all exception events (events with RECURRENCE-ID) - const exceptions = new Map>() // uid -> set of recurrence-id strings - const exceptionEvents: ScheduleEvent[] = [] - - vevents.forEach((vevent) => { - const recurrenceId = vevent.getFirstPropertyValue("recurrence-id") - if (recurrenceId) { - const uid = vevent.getFirstPropertyValue("uid") - const event = new ICAL.Event(vevent) - - // Check if exception is in range - if (event.startDate.compare(rangeEnd) <= 0 && event.endDate.compare(rangeStart) >= 0) { - exceptionEvents.push({ - start: event.startDate.toJSDate(), - end: event.endDate.toJSDate(), - summary: event.summary, - description: event.description, - recurrenceId: recurrenceId.toString(), - }) - } - - // Track exception for filtering recurring events - if (!exceptions.has(uid)) { - exceptions.set(uid, new Set()) - } - exceptions.get(uid)!.add(recurrenceId.toString()) - } - }) - - // Process regular and recurring events - const regularEvents = vevents - .filter(vevent => !vevent.getFirstPropertyValue("recurrence-id")) - .flatMap((vevent) => { - const event = new ICAL.Event(vevent) - if (event.iterator().complete) { - return [{ - start: event.startDate.toJSDate(), - end: event.endDate.toJSDate(), - summary: event.summary, - description: event.description, - recurrenceId: event.uid || event.startDate.toString(), - }] - } - const eventExceptions = exceptions.get(event.uid) || new Set() - return expandEventOccurrences(event, rangeStart, rangeEnd, eventExceptions) - }) - - return [...regularEvents, ...exceptionEvents] - .sort((a, b) => b.start.getTime() - a.start.getTime()) -} - const formatTimePair = (s: Date, e: Date): string => { const start = dayjs(s) const end = dayjs(e) @@ -216,14 +160,6 @@ export default function Schedule() { } }, [focusedDate]) - useEffect(() => { - setLoading(true) - parseCal().then((icalComp) => { - setScheduledEvents(extractScheduleEvents(icalComp)) - setLoading(false) - }) - }, []) - const groupedEvents = useMemo(() => { const grouped = new Map() scheduledEvents.forEach((event) => { From 3048475948e3f3c85d20f1ec0cc838aa607d19dc Mon Sep 17 00:00:00 2001 From: Clas Wen Date: Sat, 27 Sep 2025 12:33:09 +0800 Subject: [PATCH 2/2] Fix line breaks rendering in event descriptions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add whitespace-pre-wrap CSS class to preserve line breaks and formatting in event descriptions while maintaining proper text wrapping. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/pages/calendar/Schedule.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/calendar/Schedule.tsx b/src/pages/calendar/Schedule.tsx index af70ec3..2ee35f0 100644 --- a/src/pages/calendar/Schedule.tsx +++ b/src/pages/calendar/Schedule.tsx @@ -316,7 +316,7 @@ export default function Schedule() { {formatTimePair(event.start, event.end)} { event.description && ( -

{event.description}

+

{event.description}

) }