From 1cc4f953b3a3927f4459be37d14ffecf8d8658c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Tue, 27 Apr 2021 11:32:38 +0200 Subject: [PATCH] matrix-sdk: Small fixes --- matrix_sdk_base/src/client.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/matrix_sdk_base/src/client.rs b/matrix_sdk_base/src/client.rs index 0aaf3465..7c0d77bf 100644 --- a/matrix_sdk_base/src/client.rs +++ b/matrix_sdk_base/src/client.rs @@ -528,8 +528,11 @@ impl BaseClient { ), ); } - // TODO send and store the highlight tweak value with the event. - // Needs to associate custom data with events and to store them. + // TODO if there is an Action::SetTweak(Tweak::Highlight) we need to store + // its value with the event so a client can show if the event is highlighted + // in the UI. + // Requires the possibility to associate custom data with events and to + // store them. } timeline.events.push(e); @@ -1429,10 +1432,10 @@ impl BaseClient { .get(room_id) .and_then(|members| members.get(user_id)) { - let member = member.clone(); member .content .displayname + .clone() .unwrap_or_else(|| user_id.localpart().to_owned()) } else if let Some(member) = room.get_member(user_id).await? { member.name().to_owned() @@ -1443,7 +1446,7 @@ impl BaseClient { let room_power_levels = if let Some(AnySyncStateEvent::RoomPowerLevels(event)) = changes .state .get(room_id) - .and_then(|types| types.get(&EventType::RoomPowerLevels.to_string())) + .and_then(|types| types.get(EventType::RoomPowerLevels.as_str())) .and_then(|events| events.get("")) { event.content.clone() @@ -1459,7 +1462,7 @@ impl BaseClient { Ok(Some(PushConditionRoomCtx { room_id: room_id.clone(), - member_count: UInt::new(member_count).unwrap(), + member_count: UInt::new(member_count).unwrap_or(UInt::MAX), user_display_name, users_power_levels: room_power_levels.users, default_power_level: room_power_levels.users_default, @@ -1479,24 +1482,24 @@ impl BaseClient { ) { let room_id = &room_info.room_id; - push_rules.member_count = UInt::new(room_info.active_members_count()).unwrap(); + push_rules.member_count = UInt::new(room_info.active_members_count()).unwrap_or(UInt::MAX); if let Some(member) = changes .members .get(room_id) .and_then(|members| members.get(user_id)) { - let member = member.clone(); push_rules.user_display_name = member .content .displayname + .clone() .unwrap_or_else(|| user_id.localpart().to_owned()) } if let Some(AnySyncStateEvent::RoomPowerLevels(event)) = changes .state .get(room_id) - .and_then(|types| types.get(&EventType::RoomPowerLevels.to_string())) + .and_then(|types| types.get(EventType::RoomPowerLevels.as_str())) .and_then(|events| events.get("")) { let room_power_levels = event.content.clone();