-
Notifications
You must be signed in to change notification settings - Fork 349
feat(timeline): utilize the cache and include common relations when focusing on an event without context #5858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
CodSpeed Performance ReportMerging #5858 will not alter performanceComparing Summary
|
1b0b967 to
fa1bcaf
Compare
…ocusing on an event without context Signed-off-by: Johannes Marbach <[email protected]>
fa1bcaf to
93dc44a
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5858 +/- ##
==========================================
- Coverage 88.59% 88.57% -0.02%
==========================================
Files 362 362
Lines 102324 102338 +14
Branches 102324 102338 +14
==========================================
- Hits 90654 90650 -4
- Misses 7448 7466 +18
Partials 4222 4222 ☔ View full report in Codecov by Sentry. |
| let events = if *num_context_events == 0 { | ||
| // If no context is requested, try to load the event from the cache first and | ||
| // include common relations such as reactions and edits. | ||
| let request_config = Some(RequestConfig::default().retry_limit(3)); | ||
| let relations_filter = | ||
| Some(vec![RelationType::Annotation, RelationType::Replacement]); | ||
|
|
||
| // Load the event from the cache or, failing that, the server. | ||
| match self | ||
| .room_data_provider | ||
| .load_event_with_relations(event_id, request_config, relations_filter) | ||
| .await | ||
| { | ||
| Ok((event, related_events)) => { | ||
| let mut events = vec![event]; | ||
| events.extend(related_events); | ||
| events | ||
| } | ||
| Err(err) => { | ||
| warn!("error when loading focussed event: {err}"); | ||
| vec![] | ||
| } | ||
| } | ||
| } else { | ||
| // Start a /context request to load the focussed event and surrounding events. | ||
| let start_from_result = event_paginator | ||
| .start_from(event_id, (*num_context_events).into()) | ||
| .await | ||
| .map_err(PaginationError::Paginator)?; | ||
| start_from_result.events | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A potential issue I'm now seeing is that the if branch will leave the paginator in initial state meaning you cannot use it to extend the timeline later. This isn't really an issue for the intended event details use case but might still be problematic. Maybe this is further reason to extend TimelineFocus::PinnedEvents rather than TimelineFocus::Event? We could just add a different loader type that loads a single event only based on a specified ID.
At the moment,
TimelineController::init_focusdoesn't use the event cache at all in theTimelineFocus::Eventarm. I believe this is because the cache currently cannot load surrounding context for an event. However, when no context is requested, meaningnum_context_events = 0, this result in a potentially superfluous/contextrequest.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::PinnedEventsarm 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.Public API changes documented in changelogs (optional)