diff options
author | Tulir Asokan <tulir@maunium.net> | 2020-02-20 21:56:03 +0200 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2020-02-20 21:56:03 +0200 |
commit | db1424a06d2274f0321991660312445829df13c9 (patch) | |
tree | 47da36262279c77c05d3158a02b5b7cbf6cc1777 /ui/room-view.go | |
parent | db7d2da50cd0f4c20bc0966bff7c388c017e182f (diff) |
Add support for displaying reactions
Diffstat (limited to 'ui/room-view.go')
-rw-r--r-- | ui/room-view.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ui/room-view.go b/ui/room-view.go index 126f1ff..ab31ca7 100644 --- a/ui/room-view.go +++ b/ui/room-view.go @@ -558,6 +558,23 @@ func (view *RoomView) AddEdit(evt *event.Event) { } } +func (view *RoomView) AddReaction(evt *event.Event, key string) { + msgView := view.MessageView() + msg := msgView.getMessageByID(evt.ID) + if msg == nil { + // Message not in view, nothing to do + return + } + recalculate := len(msg.Reactions) == 0 + msg.AddReaction(key) + if recalculate { + debug.Print(msg.ReactionHeight(), msg.Height()) + // Recalculate height for message + msg.CalculateBuffer(msgView.prevPrefs, msgView.prevWidth()) + msgView.replaceBuffer(msg, msg) + } +} + func (view *RoomView) GetEvent(eventID string) ifc.Message { message, ok := view.content.messageIDs[eventID] if !ok { |