aboutsummaryrefslogtreecommitdiff
path: root/ui/messages
diff options
context:
space:
mode:
Diffstat (limited to 'ui/messages')
-rw-r--r--ui/messages/base.go3
-rw-r--r--ui/messages/parser.go4
-rw-r--r--ui/messages/textmessage.go10
3 files changed, 11 insertions, 6 deletions
diff --git a/ui/messages/base.go b/ui/messages/base.go
index d072943..567e614 100644
--- a/ui/messages/base.go
+++ b/ui/messages/base.go
@@ -54,6 +54,7 @@ type UIMessage struct {
State event.OutgoingState
IsHighlight bool
IsService bool
+ Edited bool
Source json.RawMessage
ReplyTo *UIMessage
Renderer MessageRenderer
@@ -80,6 +81,7 @@ func newUIMessage(evt *event.Event, displayname string, renderer MessageRenderer
State: evt.Gomuks.OutgoingState,
IsHighlight: false,
IsService: false,
+ Edited: len(evt.Gomuks.Edits) > 0,
Source: evt.Content.VeryRaw,
Renderer: renderer,
}
@@ -231,7 +233,6 @@ func (msg *UIMessage) SetID(id string) {
}
func (msg *UIMessage) SetIsHighlight(isHighlight bool) {
- // TODO Textmessage cache needs to be cleared
msg.IsHighlight = isHighlight
}
diff --git a/ui/messages/parser.go b/ui/messages/parser.go
index 695dac6..e1c0053 100644
--- a/ui/messages/parser.go
+++ b/ui/messages/parser.go
@@ -127,8 +127,8 @@ func ParseMessage(matrix ifc.MatrixContainer, room *rooms.Room, evt *event.Event
if len(evt.Content.GetReplyTo()) > 0 {
evt.Content.RemoveReplyFallback()
}
- if evt.Content.GetRelatesTo().Type == mautrix.RelReplace && evt.Content.NewContent != nil {
- evt.Content = *evt.Content.NewContent
+ if len(evt.Gomuks.Edits) > 0 {
+ evt.Content = *evt.Gomuks.Edits[len(evt.Gomuks.Edits)-1].Content.NewContent
}
switch evt.Content.MsgType {
case "m.text", "m.notice", "m.emote":
diff --git a/ui/messages/textmessage.go b/ui/messages/textmessage.go
index 5527677..2e27e33 100644
--- a/ui/messages/textmessage.go
+++ b/ui/messages/textmessage.go
@@ -29,9 +29,10 @@ import (
)
type TextMessage struct {
- cache tstring.TString
- buffer []tstring.TString
- Text string
+ cache tstring.TString
+ buffer []tstring.TString
+ isHighlight bool
+ Text string
}
// NewTextMessage creates a new UITextMessage object with the provided values and the default state.
@@ -85,6 +86,9 @@ func (msg *TextMessage) String() string {
}
func (msg *TextMessage) CalculateBuffer(prefs config.UserPreferences, width int, uiMsg *UIMessage) {
+ if uiMsg.IsHighlight != msg.isHighlight {
+ msg.cache = nil
+ }
msg.buffer = calculateBufferWithText(prefs, msg.getCache(uiMsg), width, uiMsg)
}