Fix m.emote messages in bare message views

This commit is contained in:
Tulir Asokan 2018-05-27 14:49:46 +03:00
parent c9e138c5e8
commit b63c451706
2 changed files with 15 additions and 5 deletions

View File

@ -469,7 +469,13 @@ func (view *MessageView) CapturePlaintext(height int) string {
meta := view.metaBuffer[index] meta := view.metaBuffer[index]
message, ok := meta.(messages.UIMessage) message, ok := meta.(messages.UIMessage)
if ok && message != prevMessage { if ok && message != prevMessage {
fmt.Fprintf(&buf, "%s <%s> %s\n", message.FormatTime(), message.Sender(), message.PlainText()) var sender string
if len(message.Sender()) > 0 {
sender = fmt.Sprintf(" <%s>", message.Sender())
} else if message.Type() == "m.emote" {
sender = fmt.Sprintf(" * %s", message.RealSender())
}
fmt.Fprintf(&buf, "%s%s %s\n", message.FormatTime(), sender, message.PlainText())
prevMessage = message prevMessage = message
} }
} }

View File

@ -58,10 +58,14 @@ func (msg *BaseMessage) calculateBufferWithText(bare bool, text tstring.TString,
msg.buffer = []tstring.TString{} msg.buffer = []tstring.TString{}
if bare { if bare {
text = tstring. newText := tstring.NewTString(msg.FormatTime())
NewTString(msg.FormatTime()). if len(msg.Sender()) > 0 {
AppendTString(tstring.NewColorTString(fmt.Sprintf(" <%s> ", msg.Sender()), msg.SenderColor())). newText = newText.AppendTString(tstring.NewColorTString(fmt.Sprintf(" <%s> ", msg.Sender()), msg.SenderColor()))
AppendTString(text) } else {
newText = newText.Append(" ")
}
newText = newText.AppendTString(text)
text = newText
} }
forcedLinebreaks := text.Split('\n') forcedLinebreaks := text.Split('\n')