fix(agenda): fix cache, event visibility, and recurring event handling#214
Open
stvsu wants to merge 2 commits into
Open
fix(agenda): fix cache, event visibility, and recurring event handling#214stvsu wants to merge 2 commits into
stvsu wants to merge 2 commits into
Conversation
The cache was expiring every 5 minutes regardless of the user's configured refresh interval. Additionally, the last-refresh timestamp was not restored from cache, so the refresh timer always started from zero instead of being aligned to when data was last fetched. Changes: - Remove CACHE_DURATION time-based expiry; cache is now valid as long as the calendar configuration hasn't changed - Restore lastRefresh from cached timestamp so the UI shows when data was last fetched even before a network refresh occurs - Replace useRef with useState for eventCalendars so calendar names render correctly when loading from cache - Replace fixed setInterval with setTimeout+setInterval so the first background refresh fires relative to cache age, not extension open time - Split fetchCalendarData into refreshFromNetwork and loadCacheAndRefresh for clarity
Event visibility: - isAllDayEvent now recognizes multi-day all-day events (not just 24h) - isFutureEvent uses end time for timed events so in-progress events remain visible; uses end date for all-day events so multi-day events stay visible until their last day passes - groupEventsByDate expands multi-day all-day events across all spanned dates so they appear under each day in the list - Past-date section rows are filtered at render time so a multi-day event that started earlier in the week doesn't show stale rows Recurring events: - RECURRENCE-ID overrides are now applied: when an occurrence is rescheduled, the rescheduled time is used instead of the original - rangeStart for rrule.between() is set to midnight today (wall-clock UTC) so in-progress occurrences are included in the expansion; isFutureEvent then filters out occurrences that have already ended - A secondary sweep of item.recurrences catches overrides whose original occurrence falls before rangeStart (e.g. rescheduled from yesterday to later today) - All RRULE processing extracted into processCalendarEvents() for testability UX: - All-day events show "All Day" as the accessory subtitle - Navigation title shows last refresh time - Cmd+R refresh action available on all list states Tests: - Integration tests for processCalendarEvents using synthetic iCal fixture strings covering future/past/in-progress events, in-progress recurring occurrences, RECURRENCE-ID overrides, and the sweep path - Tests run with TZ=UTC for deterministic date arithmetic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes several bugs in the agenda extension discovered through real-world use with iCal feeds containing recurring events, multi-day all-day events, and non-UTC timezones.
Cache reliability
eventCalendarswas auseRef— changes didn't trigger re-renders, so calendar name tags on events were stale after a refresh. Changed touseState.loadFromCachewasn't returning the cache timestamp, so the smart refresh timer couldn't align to the last fetch. Fixed.isFutureEventso events that ended since the cache was saved don't briefly appear before the network refresh completes.Event visibility
isAllDayEventonly recognised 24-hour events — multi-day all-day events (e.g. a 3-day conference) were not identified as all-day. Fixed by checking midnight boundaries rather than exact 24h duration.isFutureEventused start time — in-progress events (meeting started 10 mins ago, ends in 50 mins) were filtered out. Now uses end time for timed events and end date for all-day events.groupEventsByDatenow expands them across every date they span.Recurring events
RECURRENCE-IDoverrides were ignored — when a single occurrence of a recurring event is rescheduled, the original time was shown instead of the new time. The rrule expansion loop now checksitem.recurrencesfor each occurrence and uses the override if present.rrule.between()was called withrangeStart = new Date(), so occurrences that started before the current moment were excluded even if the event was still running. Fixed by using midnight today asrangeStartwith anisFutureEventguard to filter out occurrences that have already ended.rangeStart,rrule.between()never returns it, so the override was never processed. Added a secondary sweep ofitem.recurrencesto catch these.UX
Keyboard.Shortcut.Common.Refresh) available in all list statesTest plan
npm testpasses (119 tests)