mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Add a global Redraw method for TextWidget
Partially addresses #429, by centralizing widget drawing
This commit is contained in:
@@ -28,7 +28,6 @@ type Widget struct {
|
||||
wtf.MultiSourceWidget
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
client *Client
|
||||
idx int
|
||||
settings *Settings
|
||||
@@ -42,7 +41,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "screenName", "screenNames"),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common, true),
|
||||
|
||||
app: app,
|
||||
idx: 0,
|
||||
settings: settings,
|
||||
}
|
||||
@@ -67,9 +65,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
|
||||
// Refresh is called on the interval and refreshes the data
|
||||
func (widget *Widget) Refresh() {
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.display()
|
||||
})
|
||||
widget.display()
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
@@ -78,7 +74,7 @@ func (widget *Widget) display() {
|
||||
widget.client.screenName = widget.CurrentSource()
|
||||
tweets := widget.client.Tweets()
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("Twitter - [green]@%s[white]", widget.CurrentSource())))
|
||||
title := fmt.Sprintf("Twitter - [green]@%s[white]", widget.CurrentSource())
|
||||
|
||||
if len(tweets) == 0 {
|
||||
str := fmt.Sprintf("\n\n\n%s", wtf.CenterText("[blue]No Tweets[white]", 50))
|
||||
@@ -92,7 +88,7 @@ func (widget *Widget) display() {
|
||||
str = str + widget.format(tweet)
|
||||
}
|
||||
|
||||
widget.View.SetText(str)
|
||||
widget.Redraw(title, str, false)
|
||||
}
|
||||
|
||||
// If the tweet's Username is the same as the account we're watching, no
|
||||
|
||||
Reference in New Issue
Block a user