Repository navigation
Shared Map/Explore filters - #74
Merged
Merged
Conversation
… fixes - Date range, Friends Going and Happening Now are one shared filter state for the Map and Explore (EventFiltersProvider in the app layout, seeded from a session cookie). They survive opening an event and going back, sidebar navigation and reloads; the CAS login/logout routes clear them so each visit starts on "All dates". - Explore: Friends Going / Happening Now chips (shared component with the Map) above the topics, and a date-range picker below them limited to the Map timeline's 15 days. All three filter server-side in loadRankedFeed, so counts and "Load more" stay correct. - Reset button beside the search bar on both pages clears search, topics, Friends Going, Happening Now and dates. - Happening Now is "started and not yet ended" using the event's end time (2h fallback when it has none), shared by the Map and the feed query. - getMapEvents uses Princeton day bounds instead of the server's local midnight, which on UTC servers started "today" at 7 PM Eastern the day before and cut off the last day's evening; also includes multi-day events still in progress. - Tests for cookie parsing/clamping and the Happening Now rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Shared date & activity filters for Map and Explore
Follow-up to #73 (Map UI redesign). The Map's filters used to reset whenever you opened an event and came back, and Explore had no date filter at all. This PR makes the date range and the Friends Going / Happening Now chips one set of filters shared by the Map and Explore, adds a reset button to both pages, and fixes two time bugs along the way.
What changed
Filters carry across pages
Explore
map/_components/map-filter-pills.tsxtocomponents/events/activity-filter-pills.tsx.Calendarand quick picks (Today, This week, Next 7 days, All dates). Only today through 14 days ahead can be picked, the same 15 days as the Map timeline.loadRankedFeed), not in the browser, so "N events match" and "Load more" stay correct.Reset button (Map and Explore)
Time fixes
getMapEventsusedsetHours(0, 0, 0, 0), which follows the server's time zone. On a UTC server, "today" started at 7 PM Eastern the evening before, and the last day's evening events were dropped. It now uses Princeton calendar days. It also now includes multi-day events that started before today but are still running.lib/happening-now.ts, and the Map and the feed query both use it. Map pins now turn coral if any event at that spot is happening now, not just the first one.Implementation notes
lib/event-filters.tsholds the shared filter types, the 15-day window, cookie parsing/serializing, andclampRange.components/providers/event-filters-provider.tsxholds the filters for the whole app. It's mounted inapp/(app)/layout.tsxand seeded from the cookie.getFeedEventstakes new optionalfrom/to(YYYY-MM-DD, validated,from <= to) plusfriendsGoingandhappeningNow. Dates are converted to Princeton midnight withzonedDateTimeToDate.loadRankedFeed:rsvpssubquery over the friend IDs the feed already loads.map/_lib/map-types.tsno longer definesDateRange; it now lives inlib/event-filters.ts.TIMELINE_DAYSis now set fromFILTER_WINDOW_DAYS(still 15).Testing
bun run check,tsc --noEmitandbun run testpass. New unit tests are inlib/event-filters.test.tsandlib/happening-now.test.ts.feed-controls.db.test.tspasses against a local database (7/7). It covers sorts, paging, hidden orgs and the map query.feed-recommendations.db.test.ts, which needs its own database URL.To try it
/map, pick a date range on the timeline and turn on Happening Now.