Skip to content
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

event cache: internalize handling of the account data #3276

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Mar 26, 2024

This is a relatively simple change: this moves handling the fully read marker for a given room into the event cache, so listeners can react to a specific event for that, instead of handling themselves all the account data changes.

Not sure if that's a better API than just returning all the account data changes, so I would love feedback on this. At least it's sufficient for the UI timeline use case, and so it seems sufficient right now (and we could make it different later).

Part of #3058.

@bnjbvr bnjbvr requested a review from a team as a code owner March 26, 2024 16:03
@bnjbvr bnjbvr requested review from andybalaam and removed request for a team March 26, 2024 16:03
Copy link

codecov bot commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 84.00000% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 83.60%. Comparing base (ac0bc95) to head (9885dfe).
Report is 2 commits behind head on main.

Files Patch % Lines
crates/matrix-sdk/src/event_cache/mod.rs 69.23% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3276      +/-   ##
==========================================
- Coverage   83.61%   83.60%   -0.01%     
==========================================
  Files         238      238              
  Lines       24585    24571      -14     
==========================================
- Hits        20556    20542      -14     
  Misses       4029     4029              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@andybalaam andybalaam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, and I prefer a more-specific API in general terms. I don't think I understand well enough to comment on this exact choice of API.

crates/matrix-sdk/src/event_cache/mod.rs Outdated Show resolved Hide resolved
crates/matrix-sdk/src/event_cache/mod.rs Outdated Show resolved Hide resolved
crates/matrix-sdk/src/event_cache/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work. However, I'm not sure about this changes. The idea is to remove RoomEventCacheUpdate to replace it by a single Stream<Item = Vec<VectorDiff<SyncTimelineEvent>>>, and I don't know how this feature could fit in the next API.

@bnjbvr
Copy link
Member Author

bnjbvr commented Mar 28, 2024

The timeline will always need to listen to those account data changes, or at least the "read marker has been updated" event, so:

  • either we say the event cache only strictly streams event updates, and does not pass forward the "read marker has been updated" event — which means that the timeline now needs to listen to 1. the event cache updates for a room, 2. also the JoinedRoomUpdates for a room, which seems messy
  • or the event cache has two kinds of updates: strict event updates (via Vec<VectorDiff>), or other kind of updates (like the one introduced in this PR)
  • or instead of streaming SyncTimelineEvent, we stream a thin wrapper that also contains a bool indicating whether this event is the target of the read marker. It sounds a bit wasteful to me, since it'll be false for most updates, and it's not clear that this will cleanly extend to other info streamed from the event cache, e.g. about read receipts

Copy link
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a discussion about the possible evolution of this API in private, I'm approving this PR :-). Thanks!

(By moving handling of the fully read marker into the event cache
itself.)
@bnjbvr bnjbvr force-pushed the bnjbvr/event-cache-account-data branch from 003ff4c to 9885dfe Compare March 28, 2024 16:32
@bnjbvr bnjbvr enabled auto-merge (rebase) March 28, 2024 16:37
@bnjbvr bnjbvr merged commit 1c1053a into main Mar 28, 2024
35 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/event-cache-account-data branch March 28, 2024 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants