mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Renormalize the redraw function
Have all instances take a function Update the remaining modules to take this into account Numerous smaller refactors to make some widgets work more or less the same
This commit is contained in:
@@ -44,19 +44,19 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
room, err := GetRoom(widget.settings.roomURI, widget.settings.apiToken)
|
||||
if err != nil {
|
||||
widget.Redraw(widget.CommonSettings().Title, err.Error(), true)
|
||||
widget.Redraw(func() (string, string, bool) { return widget.CommonSettings().Title, err.Error(), true })
|
||||
return
|
||||
}
|
||||
|
||||
if room == nil {
|
||||
widget.Redraw(widget.CommonSettings().Title, "No room", true)
|
||||
widget.Redraw(func() (string, string, bool) { return widget.CommonSettings().Title, "No room", true })
|
||||
return
|
||||
}
|
||||
|
||||
messages, err := GetMessages(room.ID, widget.settings.numberOfMessages, widget.settings.apiToken)
|
||||
|
||||
if err != nil {
|
||||
widget.Redraw(widget.CommonSettings().Title, err.Error(), true)
|
||||
widget.Redraw(func() (string, string, bool) { return widget.CommonSettings().Title, err.Error(), true })
|
||||
return
|
||||
}
|
||||
widget.messages = messages
|
||||
@@ -72,7 +72,7 @@ func (widget *Widget) HelpText() string {
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) display() {
|
||||
widget.RedrawFunc(widget.content)
|
||||
widget.Redraw(widget.content)
|
||||
}
|
||||
|
||||
func (widget *Widget) content() (string, string, bool) {
|
||||
|
||||
Reference in New Issue
Block a user