Fix displayname in leave messages

This commit is contained in:
Tulir Asokan 2018-05-15 16:09:56 +03:00
parent 5884ce3233
commit 709a57d029

View File

@ -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))
}