From a680a4e52d56381101c7d16c759282bdfbf38602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Tue, 18 May 2021 16:01:11 +0200 Subject: [PATCH] Refactor displayname and fix avatar_url --- src/session/content/state_row.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/session/content/state_row.rs b/src/session/content/state_row.rs index ce476cf3..fda1bea9 100644 --- a/src/session/content/state_row.rs +++ b/src/session/content/state_row.rs @@ -74,31 +74,30 @@ impl StateRow { Some(AnyStateEventContent::RoomMember(prev)) if event.displayname != prev.displayname => { - if prev.displayname == None { + if let Some(prev_name) = prev.displayname { + if event.displayname == None { + Some(gettext!("{} removed their display name.", prev_name)) + } else { + Some(gettext!( + "{} changed their display name to {}.", + prev_name, + display_name + )) + } + } else { Some(gettext!( "{} set their display name to {}.", state.state_key(), display_name )) - } else if event.displayname == None { - Some(gettext!( - "{} removed their display name.", - prev.displayname.unwrap() - )) - } else { - Some(gettext!( - "{} changed their display name to {}.", - prev.displayname.unwrap(), - display_name - )) } } Some(AnyStateEventContent::RoomMember(prev)) if event.avatar_url != prev.avatar_url => { - if prev.displayname == None { + if prev.avatar_url == None { Some(gettext!("{} set their avatar.", display_name)) - } else if event.displayname == None { + } else if event.avatar_url == None { Some(gettext!("{} removed their avatar.", display_name)) } else { Some(gettext!("{} changed their avatar.", display_name)) @@ -113,6 +112,7 @@ impl StateRow { gettext!("{} was invited to this room.", display_name) } MembershipState::Knock => { + // TODO: Add button to invite the user. gettext!("{} requested to be invited to this room.", display_name) } MembershipState::Leave => {