Signed-in pages load about 1.9 MB of data they do not use #63

Open
opened 2026-10-03 19:44:42 +00:00 by jalenluorion · 0 comments
Member

What's wrong
Every signed-in page downloads about 1.9 MB of API data, including on pages that never show it, and some requests are duplicated. Pages load slower than they need to, especially on phones.

How to reproduce

  1. Sign in, open DevTools > Network (Fetch/XHR), tick "Disable cache" and reload /.
  2. Note events/?term=&tags=&date= (about 1.35 MB), schedule/ (about 537 KB), users/me and users/get_user_id.
  3. Open /manager: the same requests run again.
  4. Click an event on the calendar: events/{id}/tags is requested twice.

Expected
Each page loads only what it shows, and nothing is fetched twice.

Where to look

  • web/src/context/UserContext.tsx: fetchEvents runs on every page, but only SearchResultSidebar.tsx reads allEvents. Load it from Explore instead.
  • web/src/context/UserContext.tsx: fetchSchedule also runs everywhere. The navbar picker waits for currentScheduleId, which this call sets, so keep the picker working if /manager skips it.
  • web/src/app/components/Navbar.tsx: getUserID() (/users/get_user_id) runs before the schedules and role calls, but AuthContext already loads /users/me (dbUser.id). Drop it and start the other two right away.
  • web/src/app/components/ModalRender.tsx: mounts both ModalEvent and EventPopover (CSS hides one), so both fetch tags. Render only one, for example with useIsMobile().
  • "Explore shows no events by default" changes the /events/ response; coordinate.

Done when

  • / and /manager no longer request /events/.
  • /users/get_user_id is no longer requested on page load.
  • Opening an event requests its tags once.
  • Explore, the schedule picker and event details still work; the PR lists before and after transfer sizes.
**What's wrong** Every signed-in page downloads about 1.9 MB of API data, including on pages that never show it, and some requests are duplicated. Pages load slower than they need to, especially on phones. **How to reproduce** 1. Sign in, open DevTools > Network (Fetch/XHR), tick "Disable cache" and reload /. 2. Note `events/?term=&tags=&date=` (about 1.35 MB), `schedule/` (about 537 KB), `users/me` and `users/get_user_id`. 3. Open /manager: the same requests run again. 4. Click an event on the calendar: `events/{id}/tags` is requested twice. **Expected** Each page loads only what it shows, and nothing is fetched twice. **Where to look** - `web/src/context/UserContext.tsx`: `fetchEvents` runs on every page, but only `SearchResultSidebar.tsx` reads `allEvents`. Load it from Explore instead. - `web/src/context/UserContext.tsx`: `fetchSchedule` also runs everywhere. The navbar picker waits for `currentScheduleId`, which this call sets, so keep the picker working if /manager skips it. - `web/src/app/components/Navbar.tsx`: `getUserID()` (`/users/get_user_id`) runs before the schedules and role calls, but AuthContext already loads `/users/me` (`dbUser.id`). Drop it and start the other two right away. - `web/src/app/components/ModalRender.tsx`: mounts both `ModalEvent` and `EventPopover` (CSS hides one), so both fetch tags. Render only one, for example with `useIsMobile()`. - "Explore shows no events by default" changes the `/events/` response; coordinate. **Done when** - [ ] `/` and `/manager` no longer request `/events/`. - [ ] `/users/get_user_id` is no longer requested on page load. - [ ] Opening an event requests its tags once. - [ ] Explore, the schedule picker and event details still work; the PR lists before and after transfer sizes.
jalenluorion added this to the Phase 2 milestone 2026-10-03 19:44:42 +00:00
jalenluorion added this to the CMUCal project 2026-10-03 19:45:09 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ScottyLabs/cal#63
No description provided.