mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Fix race with HighlightableHelper
GetRect can lead to a race condition Add a RenderFunc method so that we can call try to wrap even more of our rendering in the thread safe `QueueUpdateDraw` method
This commit is contained in:
@@ -76,14 +76,13 @@ func (widget *Widget) display() {
|
||||
return
|
||||
}
|
||||
|
||||
title := fmt.Sprintf("%s - %s", widget.CommonSettings().Title, widget.settings.roomURI)
|
||||
|
||||
widget.Redraw(title, widget.contentFrom(widget.messages), true)
|
||||
widget.RedrawFunc(widget.content)
|
||||
}
|
||||
|
||||
func (widget *Widget) contentFrom(messages []Message) string {
|
||||
func (widget *Widget) content() (string, string, bool) {
|
||||
title := fmt.Sprintf("%s - %s", widget.CommonSettings().Title, widget.settings.roomURI)
|
||||
var str string
|
||||
for idx, message := range messages {
|
||||
for idx, message := range widget.messages {
|
||||
row := fmt.Sprintf(
|
||||
`[%s] [blue]%s [lightslategray]%s: [%s]%s [aqua]%s`,
|
||||
widget.RowColor(idx),
|
||||
@@ -97,7 +96,7 @@ func (widget *Widget) contentFrom(messages []Message) string {
|
||||
str += utils.HighlightableHelper(widget.View, row, idx, len(message.Text))
|
||||
}
|
||||
|
||||
return str
|
||||
return title, str, true
|
||||
}
|
||||
|
||||
func (widget *Widget) openMessage() {
|
||||
|
||||
Reference in New Issue
Block a user