-
Notifications
You must be signed in to change notification settings - Fork 260
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
feat(base): New RoomInfoNotableUpdateReasons::READ_RECEIPT
#3680
Conversation
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.
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.
0e73620
to
a4e47fd
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.
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)); |
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.
Does this pass?
assert!(received_reasons.is_empty());
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.
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.
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)); |
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.
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"), |
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.
make_raw_event
and make_event
should be replaced with the EventFactory
😇
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.
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"), |
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.
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…
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.
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?
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.
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 :)
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.
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.
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.
Please fold 0e73620 into the commits it belongs to (consider git-absorb next time!)
Codecov ReportAttention: Patch coverage is
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. |
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 theLATEST_EVENT
reason (it was tested inmatrix-sdk-ui
but it's better to also unit test it inmatrix-sdk-base
directly).