Fix messages sometimes overflowing until rerendering
This commit is contained in:
parent
c4175bfa70
commit
3f22fe4157
@ -53,10 +53,13 @@ type MessageView struct {
|
||||
loadingMessages int32
|
||||
|
||||
_widestSender uint32
|
||||
_prevWidestSender uint32
|
||||
|
||||
_width uint32
|
||||
_height uint32
|
||||
_prevWidth uint32
|
||||
_prevHeight uint32
|
||||
|
||||
prevMsgCount int
|
||||
prevPrefs config.UserPreferences
|
||||
|
||||
@ -84,8 +87,10 @@ func NewMessageView(parent *RoomView) *MessageView {
|
||||
messageIDs: make(map[id.EventID]*messages.UIMessage),
|
||||
msgBuffer: make([]*messages.UIMessage, 0),
|
||||
|
||||
_width: 80,
|
||||
_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))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user