Skip to content

Commit 638028b

Browse files
committed
fix(ui): Reduce number of updates in the room list.
This patch fixes a “bug” in the Room List. It's updated by `RoomInfoNotableUpdateReasons`. However, 1 reason is creating unnecessary updates: `RECENCY_STAMP`. The Room List is already updated by the Latest Event. One usage of the Latest Event is to sort the Room List by recency. Thus, since the Room List is updated by `LATEST_EVENT`, we can ignore `RECENCY_STAMP`.
1 parent ae9600e commit 638028b

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

crates/matrix-sdk-ui/src/room_list_service/room_list.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use matrix_sdk::{
2525
Client, Room, RoomRecencyStamp, RoomState, SlidingSync, SlidingSyncList,
2626
executor::{JoinHandle, spawn},
2727
};
28-
use matrix_sdk_base::RoomInfoNotableUpdate;
28+
use matrix_sdk_base::{RoomInfoNotableUpdate, RoomInfoNotableUpdateReasons};
2929
use ruma::MilliSecondsSinceUnixEpoch;
3030
use tokio::{
3131
select,
@@ -257,6 +257,22 @@ fn merge_stream_and_receiver(
257257
update = room_info_notable_update_receiver.recv() => {
258258
match update {
259259
Ok(update) => {
260+
// Filter which _reason_ can trigger an update of
261+
// the room list.
262+
//
263+
// If the update is strictly about the
264+
// `RECENCY_STAMP`, let's ignore it, because the
265+
// Latest Event type is used to sort the room list
266+
// by recency already. We don't want to trigger an
267+
// update because of `RECENCY_STAMP`.
268+
//
269+
// If the update contains more reasons than
270+
// `RECENCY_STAMP`, then it's fine. That's why we
271+
// are using `==` instead of `contains`.
272+
if update.reasons == RoomInfoNotableUpdateReasons::RECENCY_STAMP {
273+
continue;
274+
}
275+
260276
// Emit a `VectorDiff::Set` for the specific rooms.
261277
if let Some(index) = current_values.iter().position(|room| room.room_id() == update.room_id) {
262278
let mut room = current_values[index].clone();

0 commit comments

Comments
 (0)