From 2a07ff67816c035ffb35176ecb19be771abd6e39 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 7 Mar 2022 17:53:01 +0200 Subject: [PATCH] Maybe fix date change messages. Fixes #277 --- ui/message-view.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/message-view.go b/ui/message-view.go index f649e1d..2ae47c1 100644 --- a/ui/message-view.go +++ b/ui/message-view.go @@ -167,9 +167,9 @@ func (view *MessageView) AddMessage(ifcMessage ifc.Message, direction MessageDir } message.CalculateBuffer(view.config.Preferences, width) - makeDateChange := func() *messages.UIMessage { + makeDateChange := func(msg *messages.UIMessage) *messages.UIMessage { dateChange := messages.NewDateChangeMessage( - fmt.Sprintf("Date changed to %s", message.FormatDate())) + fmt.Sprintf("Date changed to %s", msg.FormatDate())) dateChange.CalculateBuffer(view.config.Preferences, width) view.appendBuffer(dateChange) return dateChange @@ -181,7 +181,7 @@ func (view *MessageView) AddMessage(ifcMessage ifc.Message, direction MessageDir } view.messagesLock.Lock() if len(view.messages) > 0 && !view.messages[len(view.messages)-1].SameDate(message) { - view.messages = append(view.messages, makeDateChange(), message) + view.messages = append(view.messages, makeDateChange(message), message) } else { view.messages = append(view.messages, message) } @@ -190,7 +190,7 @@ func (view *MessageView) AddMessage(ifcMessage ifc.Message, direction MessageDir } else if direction == PrependMessage { view.messagesLock.Lock() if len(view.messages) > 0 && !view.messages[0].SameDate(message) { - view.messages = append([]*messages.UIMessage{message, makeDateChange()}, view.messages...) + view.messages = append([]*messages.UIMessage{message, makeDateChange(view.messages[0])}, view.messages...) } else { view.messages = append([]*messages.UIMessage{message}, view.messages...) }