HAR analysis: Asset view → Place view (tab switch)
Source: control room asset -> control room place.har — switching tabs from Asset view to Place view within the same control room (both under /map/).
Flow: User is on Map → Assets tab. They switch to Map → Places tab. Same control room, same map; assets, events, and places were already loaded for the map.
Observation
When switching from Asset view to Place view, assets, events, and places are all re-fetched even though they were just loaded:
| API | Expected (data already in store) | Observed |
|---|---|---|
GET /controlrooms/{id}/assets?size=500 |
0× (already loaded) | 1× |
POST /controlrooms/{id}/events/search |
0× (already loaded) | 1× |
GET /controlrooms/{id}/places |
0× (already loaded) | 1× |
POST /cycles/summary |
0× or 1× | 2× (duplicate) |
GET /controlrooms/{id}/assets?size=500&page=1 |
0× | 1× |
Asset polling (recordedAfter) |
1× per interval | 2–3× with same timestamp |
Root cause (code-validated)
The loadAssetsOnNavigate, loadPlacesOnNavigate, and loadEventsOnNavigate effects in control-room.effects.ts fire on every ROUTER_NAVIGATED when the URL matches their patterns.
Patterns (from router.constants.ts):
MAP_OR_ASSETS_URL_PATTERNS= [//map/, //assets/]MAP_PLACES_INSIGHTS_URL_PATTERNS= [//map/, //places/, //insights/, //assets/, …]MAP_EVENTS_INSIGHTS_URL_PATTERNS= [//map/, //events/, //insights/, //assets/, …]
RouterService.matchesRoute() returns true if any pattern matches the URL. The URL /control-rooms/:id/map/places contains /map/, so it matches:
- loadAssetsOnNavigate — matches
/map/→ dispatchesloadAssets+loadAssetTypes - loadPlacesOnNavigate — matches
/places/→ dispatchesloadPlaces+loadPlaceTypes - loadEventsOnNavigate — matches
/map/→ dispatchesloadEvents+loadEventTypes
Result: On every tab switch within the map (assets ↔ events ↔ places), all three effects fire and re-fetch data that is already in the store.
Files: webapp/web/src/app/store/control-room/control-room.effects.ts, router.constants.ts, router.service.ts.
Suggested fix
- Guard on “same control room + already loaded” — Before dispatching load actions, check if we’re navigating within the same control room and if assets/events/places are already loaded (e.g.
selectLoadPlaceViewState === Success). - Narrow pattern match — Only trigger load when navigating into a map sub-route from outside (e.g. from rules or launchpad), not when switching between
/map/assets,/map/events,/map/places. - Use
RouterServicewith previous URL — Compare previous URL vs current URL; if both are under/map/with same controlRoomId, skip reload.
Estimated impact
- Before: ~10+ redundant API calls per tab switch (assets, events, places, cycles, etc.).
- After fix: 0 extra calls on tab switch — reuse store.