diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-05-15 16:09:56 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-05-15 17:55:08 +0300 |
commit | 709a57d029e6d6728cd9a021a1113b5bb2315b3f (patch) | |
tree | 575a0212974f13e2b9d61a28d57f191b90dd5e04 | |
parent | 5884ce32336b93363bfbcc145e98cc5ac5006a8b (diff) |
Fix displayname in leave messages
-rw-r--r-- | ui/messages/parser/parser.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/ui/messages/parser/parser.go b/ui/messages/parser/parser.go index 158e27b..0c250da 100644 --- a/ui/messages/parser/parser.go +++ b/ui/messages/parser/parser.go @@ -96,6 +96,9 @@ func getMembershipEventContent(room *rooms.Room, evt *gomatrix.Event) (sender st if evt.Unsigned.PrevContent != nil { prevMembership, _ = evt.Unsigned.PrevContent["membership"].(string) prevDisplayname, _ = evt.Unsigned.PrevContent["displayname"].(string) + if len(prevDisplayname) == 0 { + prevDisplayname = *evt.StateKey + } } if membership != prevMembership { @@ -117,6 +120,9 @@ func getMembershipEventContent(room *rooms.Room, evt *gomatrix.Event) (sender st text.Colorize(0, len(senderDisplayname), widget.GetHashColor(evt.Sender)) text.Colorize(len(senderDisplayname)+len(" kicked "), len(displayname), widget.GetHashColor(*evt.StateKey)) } else { + if displayname == *evt.StateKey { + displayname = prevDisplayname + } text = tstring.NewColorTString(fmt.Sprintf("%s left the room.", displayname), tcell.ColorRed) text.Colorize(0, len(displayname), widget.GetHashColor(*evt.StateKey)) } |