feat(timeline): utilize the cache and include common relations when focusing on an event without context
At the moment, TimelineController::init_focus doesn't use the event cache at all in the TimelineFocus::Event arm. I believe this is because the cache currently cannot load surrounding context for an event. However, when no context is requested, meaning num_context_events = 0, this result in a potentially superfluous /context request.
This pull request, differentiates this special case and attempts to load the event from the cache before falling back to the server.
Additionally, common relations (reactions & edits) are included, if possible. This is similar to the behavior in the TimelineFocus::PinnedEvents arm and allows using focused timelines to power event details views.
Open questions:
-
Given the similarity to the
TimelineFocus::PinnedEventsbehavior, I'm not sure if it might be better to generalizeTimelineFocus::PinnedEventsto support both cases. -
It would be great if
TimelineFocus::Eventwould make use of the event cache regardless of whether context was requested or not. I'm not sure if that's feasibly possible though. -
[x] Public API changes documented in changelogs (optional)
CodSpeed Performance Report
Merging #5858 will not alter performance
Comparing Johennes:johannes/focus-no-context (1c75ffc) with main (3b5b0f8)
Summary
✅ 50 untouched
Codecov Report
:x: Patch coverage is 84.61538% with 4 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 88.64%. Comparing base (ec44c74) to head (37d56be).
:warning: Report is 31 commits behind head on main.
:white_check_mark: All tests successful. No failed tests found.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| ...rates/matrix-sdk-ui/src/timeline/controller/mod.rs | 84.61% | 3 Missing and 1 partial :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #5858 +/- ##
==========================================
- Coverage 88.65% 88.64% -0.01%
==========================================
Files 362 362
Lines 103146 103163 +17
Branches 103146 103163 +17
==========================================
+ Hits 91440 91446 +6
- Misses 7458 7469 +11
Partials 4248 4248
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Can you add a test when num_context_events = 0 to test the new code please?
Have added two tests with e27d0d5b7e189c2176d44753dbaefcb457427951 / 37d56be98fcdca5d6f4d2728e02697cbcbd7309e.
Hm, I will have to look into why the tests suddenly fail now. I'm out on vacation though and will probably only be able to get back to this after the holidays, apologies.