-
Notifications
You must be signed in to change notification settings - Fork 288
fix(sdk): RoomEventCache::event
looks inside the store
#4708
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
fix(sdk): RoomEventCache::event
looks inside the store
#4708
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4708 +/- ##
==========================================
+ Coverage 85.96% 85.97% +0.01%
==========================================
Files 290 290
Lines 33995 34065 +70
==========================================
+ Hits 29224 29288 +64
- Misses 4771 4777 +6 ☔ View full report in Codecov by Sentry. |
9c1d4cd
to
985807a
Compare
985807a
to
ca62b1f
Compare
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.
Nice, thanks!
crates/matrix-sdk-base/src/event_cache/store/integration_tests.rs
Outdated
Show resolved
Hide resolved
ca62b1f
to
78c22d7
Compare
This patch adds the method `find_event` on the `EventCacheStore` trait. It helps to find a single event from the store.
This patch fixes `RoomEventCache::event` to look inside `RoomEvents` but also inside the `EventCacheStore` to look for an event. It ultimately fallbacks to `AllEventsCache` because we can't get rid of it for the moment.
0b3b134
to
5cc427d
Compare
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.
Just one more question about fusing two methods in the in-memory event cache store implementation, and we should be good to go, thanks!
.await | ||
.unwrap(); | ||
|
||
// Now let's find out the event. |
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.
Need to double-check with a native speaker, but I find it weird to have find out
here, I'd just say find
I suppose.
// Now let's find out the event. | |
// Now let's find the event. |
/// Return an iterator over all items. | ||
pub fn items(&self) -> impl Iterator<Item = (Position, &Item, &RoomId)> { | ||
self.items.iter().filter_map(|item_row| { | ||
if let Either::Item(item) = &item_row.item { | ||
Some((item_row.position, item, item_row.room_id.as_ref())) | ||
} else { | ||
None | ||
} | ||
}) | ||
} |
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.
Seems this is unordered_items
with an extra return value; can we fuse those two functions?
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.
oh i found the difference now, unordered_items
is keyed by room. Maybe the names could be clearer…
if let Some(event) = maybe_position_and_event.map(|(_position, event)| event) { | ||
Some(event) | ||
} | ||
// Search in `AllEventsCache` for known events that are not stored. |
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.
Can you put the comment either above the if / else if
chain, or inside the arm that relates to it? I find it super ugly and confusing to have comments break else if
chains, because it breaks the flow of reading :|
lol i forgot i approved yesterday |
Oh damn, sorry!! |
opened #4711 with my review suggestions! |
This patch fixes a bug in
RoomEventCache::event
since #4632 has landed.RoomEvents
now likely contains a partial view of the events, i.e. they are not all loaded from the store to memory.A new
EventCacheStore::find_event
is added to look for an event in the store.RoomEventCache::event
uses it to use the store, with a fallback toAllEventsCache
because we can't get rid of it right now (see #3886).