aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2020-04-19 22:53:26 +0300
committerTulir Asokan <tulir@maunium.net>2020-04-19 22:53:26 +0300
commit3f22fe4157b99171049e8b263d47b21284613f2f (patch)
treeb18169d9222a273302a1d4a90fa27f488711999e /ui
parentc4175bfa703ef299938a10ca8ed50be35c873632 (diff)
Fix messages sometimes overflowing until rerendering
Diffstat (limited to 'ui')
-rw-r--r--ui/message-view.go35
1 files changed, 23 insertions, 12 deletions
diff --git a/ui/message-view.go b/ui/message-view.go
index e96a588..596b9b0 100644
--- a/ui/message-view.go
+++ b/ui/message-view.go
@@ -52,13 +52,16 @@ type MessageView struct {
// Used for locking
loadingMessages int32
- _widestSender uint32
- _width uint32
- _height uint32
- _prevWidth uint32
- _prevHeight uint32
- prevMsgCount int
- prevPrefs config.UserPreferences
+ _widestSender uint32
+ _prevWidestSender uint32
+
+ _width uint32
+ _height uint32
+ _prevWidth uint32
+ _prevHeight uint32
+
+ prevMsgCount int
+ prevPrefs config.UserPreferences
messageIDLock sync.RWMutex
messageIDs map[id.EventID]*messages.UIMessage
@@ -84,11 +87,13 @@ func NewMessageView(parent *RoomView) *MessageView {
messageIDs: make(map[id.EventID]*messages.UIMessage),
msgBuffer: make([]*messages.UIMessage, 0),
- _width: 80,
- _widestSender: 5,
- _prevWidth: 0,
- _prevHeight: 0,
- prevMsgCount: -1,
+ _widestSender: 5,
+ _prevWidestSender: 0,
+
+ _width: 80,
+ _prevWidth: 0,
+ _prevHeight: 0,
+ prevMsgCount: -1,
}
}
@@ -308,6 +313,7 @@ func (view *MessageView) replaceBuffer(original *messages.UIMessage, new *messag
func (view *MessageView) recalculateBuffers() {
prefs := view.config.Preferences
recalculateMessageBuffers := view.width() != view.prevWidth() ||
+ view.widestSender() != view.prevWidestSender() ||
view.prevPrefs.BareMessageView != prefs.BareMessageView ||
view.prevPrefs.DisableImages != prefs.DisableImages
view.messagesLock.RLock()
@@ -465,6 +471,7 @@ func (view *MessageView) setSize(width, height int) {
func (view *MessageView) updatePrevSize() {
atomic.StoreUint32(&view._prevWidth, atomic.LoadUint32(&view._width))
atomic.StoreUint32(&view._prevHeight, atomic.LoadUint32(&view._height))
+ atomic.StoreUint32(&view._prevWidestSender, atomic.LoadUint32(&view._widestSender))
}
func (view *MessageView) prevHeight() int {
@@ -475,6 +482,10 @@ func (view *MessageView) prevWidth() int {
return int(atomic.LoadUint32(&view._prevWidth))
}
+func (view *MessageView) prevWidestSender() int {
+ return int(atomic.LoadUint32(&view._prevWidestSender))
+}
+
func (view *MessageView) widestSender() int {
return int(atomic.LoadUint32(&view._widestSender))
}