matrix-sdk: Small fixes

master
Kévin Commaille 2021-04-27 11:32:38 +02:00
parent f8bc9f3dc9
commit 1cc4f953b3
No known key found for this signature in database
GPG Key ID: 296D60AE1E61661C
1 changed files with 11 additions and 8 deletions

View File

@ -528,8 +528,11 @@ impl BaseClient {
), ),
); );
} }
// TODO send and store the highlight tweak value with the event. // TODO if there is an Action::SetTweak(Tweak::Highlight) we need to store
// Needs to associate custom data with events and to store them. // 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); timeline.events.push(e);
@ -1429,10 +1432,10 @@ impl BaseClient {
.get(room_id) .get(room_id)
.and_then(|members| members.get(user_id)) .and_then(|members| members.get(user_id))
{ {
let member = member.clone();
member member
.content .content
.displayname .displayname
.clone()
.unwrap_or_else(|| user_id.localpart().to_owned()) .unwrap_or_else(|| user_id.localpart().to_owned())
} else if let Some(member) = room.get_member(user_id).await? { } else if let Some(member) = room.get_member(user_id).await? {
member.name().to_owned() member.name().to_owned()
@ -1443,7 +1446,7 @@ impl BaseClient {
let room_power_levels = if let Some(AnySyncStateEvent::RoomPowerLevels(event)) = changes let room_power_levels = if let Some(AnySyncStateEvent::RoomPowerLevels(event)) = changes
.state .state
.get(room_id) .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("")) .and_then(|events| events.get(""))
{ {
event.content.clone() event.content.clone()
@ -1459,7 +1462,7 @@ impl BaseClient {
Ok(Some(PushConditionRoomCtx { Ok(Some(PushConditionRoomCtx {
room_id: room_id.clone(), 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, user_display_name,
users_power_levels: room_power_levels.users, users_power_levels: room_power_levels.users,
default_power_level: room_power_levels.users_default, default_power_level: room_power_levels.users_default,
@ -1479,24 +1482,24 @@ impl BaseClient {
) { ) {
let room_id = &room_info.room_id; 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 if let Some(member) = changes
.members .members
.get(room_id) .get(room_id)
.and_then(|members| members.get(user_id)) .and_then(|members| members.get(user_id))
{ {
let member = member.clone();
push_rules.user_display_name = member push_rules.user_display_name = member
.content .content
.displayname .displayname
.clone()
.unwrap_or_else(|| user_id.localpart().to_owned()) .unwrap_or_else(|| user_id.localpart().to_owned())
} }
if let Some(AnySyncStateEvent::RoomPowerLevels(event)) = changes if let Some(AnySyncStateEvent::RoomPowerLevels(event)) = changes
.state .state
.get(room_id) .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("")) .and_then(|events| events.get(""))
{ {
let room_power_levels = event.content.clone(); let room_power_levels = event.content.clone();