From 152b89ed5e6a4a3edbfc40222b4388049a213b82 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 22 Mar 2018 21:44:46 +0200 Subject: Add support for m.emote. Fixes #6 --- ui/widget/message-view.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'ui/widget/message-view.go') diff --git a/ui/widget/message-view.go b/ui/widget/message-view.go index fe906b5..a4ba236 100644 --- a/ui/widget/message-view.go +++ b/ui/widget/message-view.go @@ -74,8 +74,8 @@ func NewMessageView() *MessageView { } } -func (view *MessageView) NewMessage(id, sender, text string, timestamp time.Time) *types.Message { - return types.NewMessage(id, sender, text, +func (view *MessageView) NewMessage(id, sender, msgtype, text string, timestamp time.Time) *types.Message { + return types.NewMessage(id, sender, msgtype, text, timestamp.Format(view.TimestampFormat), timestamp.Format(view.DateFormat), GetHashColor(sender)) @@ -151,6 +151,8 @@ func (view *MessageView) AddMessage(message *types.Message, direction MessageDir msg, messageExists := view.messageIDs[message.ID] if msg != nil && messageExists { message.CopyTo(msg) + message = msg + message.SetIsSending(false) direction = IgnoreMessage } @@ -338,9 +340,9 @@ func (view *MessageView) Draw(screen tcell.Screen) { if len(meta.GetTimestamp()) > 0 { view.writeLine(screen, meta.GetTimestamp(), x, y+line, meta.GetTimestampColor()) } - if len(meta.GetSender()) > 0 && (prevMeta == nil || meta.GetSender() != prevMeta.GetSender()) { + if prevMeta == nil || meta.GetSender() != prevMeta.GetSender() { view.writeLineRight( - screen, meta.GetSender(), + screen, meta.GetDisplaySender(), x+usernameOffsetX, y+line, view.widestSender, meta.GetSenderColor()) } -- cgit v1.2.3