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

sdk: Allow to track ambiguity changes per-room #3062

Merged
merged 7 commits into from
Feb 5, 2024

Conversation

zecakeh
Copy link
Collaborator

@zecakeh zecakeh commented Jan 27, 2024

This PR had the main goal to allow to follow ambiguity changes per-room, without relying on the SyncResponse. We need this because we keep the members list of the current room in memory for mention autocompletion in Fractal.

As a bonus, we use that to update profiles in the Timeline when there is an ambiguity change (ticks one of the boxes in #1103).

  • Public API changes documented in changelogs (optional)

@zecakeh zecakeh requested a review from a team as a code owner January 27, 2024 17:02
@zecakeh zecakeh requested review from bnjbvr and removed request for a team January 27, 2024 17:02
@zecakeh zecakeh changed the title Ambiguity changes sdk: Allow to track ambiguity changes per-room Jan 27, 2024
@zecakeh zecakeh closed this Jan 28, 2024
@zecakeh zecakeh reopened this Jan 28, 2024
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 PR. I like it. I particularly appreciate the tests!

I've a few feedback, but overall it's a good patch.

crates/matrix-sdk/tests/integration/client.rs Show resolved Hide resolved
crates/matrix-sdk/src/sync.rs Outdated Show resolved Hide resolved
crates/matrix-sdk/src/sync.rs Outdated Show resolved Hide resolved
crates/matrix-sdk/src/sync.rs Outdated Show resolved Hide resolved

let mut state = self.state.write().await;
let mut entries = state.items.entries();
while let Some(mut entry) = entries.next() {
Copy link
Member

Choose a reason for hiding this comment

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

Why not:

for mut entry in entries {}

?

Copy link
Collaborator Author

@zecakeh zecakeh Jan 29, 2024

Choose a reason for hiding this comment

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

ObservableVectorEntries does not implement Iterator/IntoIterator, it just has a .next() method.

Copy link
Member

Choose a reason for hiding this comment

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

@jplatte Any reason why ObservableVectorEntries doesn't implement an Iterator?

@bnjbvr bnjbvr removed their request for review January 29, 2024 10:30
Makes AmbiguityChange easier to use, especially outside of SyncResponse,
where we might not have the m.room.member event.

Signed-off-by: Kévin Commaille <[email protected]>
@zecakeh
Copy link
Collaborator Author

zecakeh commented Jan 30, 2024

Rebased on main for the CI fix

Copy link

codecov bot commented Jan 30, 2024

Codecov Report

Attention: 13 lines in your changes are missing coverage. Please review.

Comparison is base (b9ef5d6) 83.73% compared to head (3599e57) 83.70%.

❗ Current head 3599e57 differs from pull request most recent head e0bda80. Consider uploading reports for the commit e0bda80 to get more accurate results

Files Patch % Lines
crates/matrix-sdk-ui/src/timeline/inner/mod.rs 67.74% 10 Missing ⚠️
crates/matrix-sdk-ui/src/timeline/builder.rs 62.50% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3062      +/-   ##
==========================================
- Coverage   83.73%   83.70%   -0.04%     
==========================================
  Files         224      223       -1     
  Lines       23497    23408      -89     
==========================================
- Hits        19675    19593      -82     
+ Misses       3822     3815       -7     

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

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.

All good to me. Please update the CHANGELOG and we are good :-).

@@ -5,6 +5,8 @@ Breaking changes:
- Replace the `Notification` type from Ruma in `SyncResponse` and `Client::register_notification_handler`
by a custom one
- `Room::can_user_redact` and `Member::can_redact` are split between `*_redact_own` and `*_redact_other`
- `RoomUpdate` also contains the ambiguity changes of a `Room` with `AmbiguityCache` containing the
Copy link
Member

Choose a reason for hiding this comment

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

I reckon this might be updated since ambiguity_changes are part of LeftJoin, JoinedRoom and InvitedRoom right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I updated the changelog.

Signed-off-by: Kévin Commaille <[email protected]>
@zecakeh
Copy link
Collaborator Author

zecakeh commented Feb 4, 2024

I merged main into the branch to solve a conflict. That makes the ambiguity changes go through the event graph untouched, so I am not sure it's the best solution.

@Hywan
Copy link
Member

Hywan commented Feb 5, 2024

Let's consider it's fine for the moment.

@Hywan Hywan merged commit 6e685e2 into matrix-org:main Feb 5, 2024
31 of 32 checks passed
@zecakeh zecakeh deleted the ambiguity-changes branch February 9, 2024 09:24
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.

2 participants