feat(calendar): lazy-load events by date range with cache-first refresh#603
Open
tompscanlan wants to merge 1 commit into
Open
feat(calendar): lazy-load events by date range with cache-first refresh#603tompscanlan wants to merge 1 commit into
tompscanlan wants to merge 1 commit into
Conversation
Replace full-table LiveQuery with range-based loading. LiveQuery's reactivity added no value here — only our own code writes to comp_calendar_event after API fetches, so it was re-scanning all events on every write we already had the data for. - datesSet callback drives lazy-load per visible date range - 5-minute TTL for cache freshness, SQLite for instant paint on revisit - Generation counter discards stale API responses on rapid navigation - Reactive $state array replaces imperative setOption for event updates - Pure utility functions extracted to calendar-utils.ts with 16 unit tests - fetchGroupEvents accepts optional startDate/endDate query params Addresses feedback about calendar events appearing out-of-date.
c7124c8 to
237ea8e
Compare
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
Addresses feedback about calendar events being stale/out-of-date.
Why replace LiveQuery?
The old approach used a
LiveQueryoncomp_calendar_eventto reactively display events. But LiveQuery's reactivity added no value here — nothing else writes to that table, only our own code after fetching from the OpenMeet API. The result was:insert or replacetriggered LiveQuery to re-run a query over data we just fetchedWhat replaces it
A cache-first architecture that lazy-loads events by visible date range:
datesSetcallback fetches only the month/day the user is viewing, passesstartDate/endDatequery params to the APIFiles changed
+page.svelteloadEventsForRange,loadFromSQLite,writeToSQLite, generation counter, loading overlaycalendar-utils.ts(new)calendar-utils.test.ts(new)openmeet.tsstartDate/endDateparams tofetchGroupEventscalendar.svelte.tsCalendarEventinterface andcalendarEventsQuery(replaced by range-based loading)Test plan
pnpm test— 16 tests in calendar-utils.test.ts)