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

feat(base): New RoomInfoNotableUpdateReasons::READ_RECEIPT #3680

Merged

Conversation

Hywan
Copy link
Member

@Hywan Hywan commented Jul 10, 2024

Please review this PR patch-by-patch.

tl;dr: this PR adds the READ_RECEIPT reason for the room info notable update, in order to refresh the room list for this particular reason. This PR also adds a missing test for the LATEST_EVENT reason (it was tested in matrix-sdk-ui but it's better to also unit test it in matrix-sdk-base directly).

Hywan added 2 commits July 10, 2024 14:42
This patch removes the mention of a returned value whilst the function
returns nothing.
…sent.

This patch adds a missing test to ensure that a
`RoomInfoNotableUpdateReason::RECENCY_TIMESTAMP` is correctly sent.
@Hywan Hywan requested a review from a team as a code owner July 10, 2024 13:05
@Hywan Hywan requested review from andybalaam and bnjbvr and removed request for a team and andybalaam July 10, 2024 13:05
Hywan added 3 commits July 10, 2024 15:11
This patch adds the new `RoomInfoNotableUpdateReasons::READ_RECEIPT`
reason. It detects it and adds the test to ensure it's sent as expected.
…EAD_RECEIPT`.

This patch listens to `RoomInfoNotableUpdateReasons::READ_RECEIPT` to
update the `RoomLIst` stream.
@Hywan Hywan force-pushed the feat-base-room-info-notable-update-read-receipts branch from 0e73620 to a4e47fd Compare July 10, 2024 13:11
Copy link
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

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

Thanks!

room_info_notable_update_stream.recv().await,
Ok(RoomInfoNotableUpdate { room_id: received_room_id, reasons: received_reasons }) => {
assert_eq!(received_room_id, room_id);
assert!(!received_reasons.contains(RoomInfoNotableUpdateReasons::RECENCY_TIMESTAMP));
Copy link
Member

Choose a reason for hiding this comment

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

Does this pass?

assert!(received_reasons.is_empty());

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer to test the reason is not present, in case other reasons may exist. We don't care about the other reasons at this step. Tests are less likely to break in the future if these kind of assertions.

crates/matrix-sdk-base/src/sliding_sync.rs Outdated Show resolved Hide resolved
Ok(RoomInfoNotableUpdate { room_id: received_room_id, reasons: received_reasons }) => {
assert_eq!(received_room_id, room_id);
dbg!(&received_reasons);
assert!(!received_reasons.contains(RoomInfoNotableUpdateReasons::READ_RECEIPT));
Copy link
Member

Choose a reason for hiding this comment

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

Same as before, can this be a check that reasons is empty?

// When I send sliding sync response containing a couple of events with no read receipt.
let room_id = room_id!("!r:e.uk");
let events = vec![
make_raw_event("m.room.message", "$3"),
Copy link
Member

Choose a reason for hiding this comment

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

make_raw_event and make_event should be replaced with the EventFactory 😇

Copy link
Member Author

Choose a reason for hiding this comment

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

This entire test suite should be revisited. Later. For another time. But I agree!

let events = vec![
make_raw_event("m.room.message", "$3"),
make_raw_event("m.room.message", "$4"),
make_raw_event("m.read", "$5"),
Copy link
Member

Choose a reason for hiding this comment

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

Technically this is wrong, as this will create a m.read event with the content of a m.room.message event; it seems compute_unread_counts() still does something with it (store it, maybe?), but this could be a bit better…

Copy link
Member Author

@Hywan Hywan Jul 10, 2024

Choose a reason for hiding this comment

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

There is no RoomReadReceipt before, and now there is one, so the previous and the new one are different, which triggers something. Do you have a better minimal test in mind?

Copy link
Member

Choose a reason for hiding this comment

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

All I'm saying is that the m.read event should be created in a better way (with a proper content property), because it doesn't make sense now :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Since you've approved the PR, I understand it's fine for this particular test. The read receipt mechanism is already pretty well test. Here we only want to test the notable update reason is triggered, which is fine for the moment.

Copy link
Member

Choose a reason for hiding this comment

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

Please fold 0e73620 into the commits it belongs to (consider git-absorb next time!)

Copy link

codecov bot commented Jul 10, 2024

Codecov Report

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

Project coverage is 84.31%. Comparing base (d78b682) to head (a4e47fd).
Report is 4 commits behind head on main.

Files Patch % Lines
...s/matrix-sdk-ui/src/room_list_service/room_list.rs 0.00% 3 Missing ⚠️
crates/matrix-sdk-base/src/sliding_sync.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3680      +/-   ##
==========================================
- Coverage   84.31%   84.31%   -0.01%     
==========================================
  Files         258      258              
  Lines       26601    26607       +6     
==========================================
+ Hits        22429    22433       +4     
- Misses       4172     4174       +2     

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

@Hywan Hywan merged commit 25bb8e9 into matrix-org:main Jul 10, 2024
40 checks passed
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