Skip to content

fix(base,sdk,ui): Synchronize sliding sync room's avatar with regular Room #3078

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

Merged
merged 3 commits into from
Feb 1, 2024

Conversation

Hywan
Copy link
Member

@Hywan Hywan commented Feb 1, 2024

This PR must be reviewed commit by commit.

To update the avatar of a room, one has to look up in the state event.
That's the canonical way to do. For Sliding Sync, it means looking
inside the required_state field of the v4::SlidingSyncRoom. This
case already works and was tested.

However, a v4::SlidingSyncRoom comes with a direct avatar field.
It's another way to know the avatar URL of the room. This case was
handled and tested in matrix_sdk::sliding_sync::SlidingSyncRoom, but
it was never propagated into the proper sync mechanism. So when the
avatar field was set up, matrix_sdk::sliding_sync::SlidingSyncRoom
was holding this information, and the avatar wasn't defined in the
proper Room: SlidingSyncRoom has to look up inside the Room as
a fallback.

This fallback mechanism was present in
matrix_sdk::sliding_sync::SlidingSyncRoom, but also in
matrix_sdk_ui::room_list::Room.

These patches fix this “fallback” mechanism.

It's the first patch of a series to remove tech debt about sliding sync room.


@Hywan Hywan requested a review from a team as a code owner February 1, 2024 08:39
@Hywan Hywan requested review from andybalaam and bnjbvr and removed request for a team February 1, 2024 08:39
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.

I'm pretty sure this reintroduces the bug tested by test_avatar_set_then_unset, which has been removed. We need to be able to unset an avatar when the received room avatar is set to null.

Can you reintroduce a similar test, please? (See commit and accompanying issue to understand what it fixed.)

@bnjbvr bnjbvr removed the request for review from andybalaam February 1, 2024 09:03
@Hywan Hywan force-pushed the fix-sdk-sliding-sync-room-avatar-url branch from 56d7f38 to 675ea14 Compare February 1, 2024 09:37
@Hywan
Copy link
Member Author

Hywan commented Feb 1, 2024

@bnjbvr You're right. I've updated the test suite, and added the handling of null.

@Hywan Hywan requested a review from bnjbvr February 1, 2024 09:37
@Hywan Hywan force-pushed the fix-sdk-sliding-sync-room-avatar-url branch from 675ea14 to 7f63fc0 Compare February 1, 2024 09:43
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! Small suggestion below, shouldn't require another review.

Copy link

codecov bot commented Feb 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f64af12) 83.72% compared to head (9ef9251) 83.75%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3078      +/-   ##
==========================================
+ Coverage   83.72%   83.75%   +0.03%     
==========================================
  Files         224      224              
  Lines       23514    23521       +7     
==========================================
+ Hits        19688    19701      +13     
+ Misses       3826     3820       -6     

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

Hywan added 3 commits February 1, 2024 10:58
To update the avatar of a room, one has to look up in the state event.
That's the canonical way to do. For Sliding Sync, it means looking
inside the `required_state` field of the `v4::SlidingSyncRoom`. This
case already works and was tested.

However, a `v4::SlidingSyncRoom` comes with a direct `avatar` field.
It's another way to know the avatar URL of the room. This case was
handled and tested in `matrix_sdk::sliding_sync::SlidingSyncRoom`, but
it was never propagated into the proper sync mechanism. So when the
`avatar` field was set up, `matrix_sdk::sliding_sync::SlidingSyncRoom`
was holding this information, and the `avatar` wasn't defined in the
proper `Room`: `SlidingSyncRoom` has to look up inside the `Room` as
a fallback.

This patch is the first one to fix this “fallback” mechanism.

The `avatar` field of a `v4::SlidingSyncRoom` now triggers an update to
the new `RoomInfo::update_avatar` method (à la `update_name`), via
`process_room_properties`.
With the previous commit, the avatar is properly synchronized with the
`Room`. The result is that `SlidingSyncRoom` no longer needs to hold
the `avatar_url`.
…ice::Room`.

`SlidingSyncRoom` no longer has an `avatar_url` method.
`room_list::Room` no longer needs to check first in sliding sync then in
`Room` as a fallback.

This patch removes the `room_list::Room::avatar_url` method.

This patch also implements `Deref` for `room_list::Room` to
`matrix_sdk::Room`, to make our lifes easier.
@Hywan Hywan force-pushed the fix-sdk-sliding-sync-room-avatar-url branch from 7f63fc0 to 9ef9251 Compare February 1, 2024 09:58
@Hywan Hywan enabled auto-merge February 1, 2024 10:07
@Hywan Hywan disabled auto-merge February 1, 2024 10:08
@Hywan Hywan enabled auto-merge February 1, 2024 10:15
@Hywan Hywan merged commit 39241c5 into matrix-org:main Feb 1, 2024
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