mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Convert the bulk of modules over to RedrawFunc
This commit is contained in:
@@ -32,41 +32,38 @@ func (widget *Widget) Refresh() {
|
||||
return
|
||||
}
|
||||
|
||||
builds, err := widget.Client.BuildsFor()
|
||||
|
||||
title := fmt.Sprintf("%s - Builds", widget.CommonSettings().Title)
|
||||
var content string
|
||||
wrap := false
|
||||
if err != nil {
|
||||
wrap = true
|
||||
content = err.Error()
|
||||
} else {
|
||||
content = widget.contentFrom(builds)
|
||||
}
|
||||
|
||||
widget.Redraw(title, content, wrap)
|
||||
widget.RedrawFunc(widget.content)
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) contentFrom(builds []*Build) string {
|
||||
var str string
|
||||
for idx, build := range builds {
|
||||
if idx > 10 {
|
||||
return str
|
||||
}
|
||||
func (widget *Widget) content() (string, string, bool) {
|
||||
builds, err := widget.Client.BuildsFor()
|
||||
|
||||
str += fmt.Sprintf(
|
||||
"[%s] %s-%d (%s) [white]%s\n",
|
||||
buildColor(build),
|
||||
build.Reponame,
|
||||
build.BuildNum,
|
||||
build.Branch,
|
||||
build.AuthorName,
|
||||
)
|
||||
title := fmt.Sprintf("%s - Builds", widget.CommonSettings().Title)
|
||||
var str string
|
||||
wrap := false
|
||||
if err != nil {
|
||||
wrap = true
|
||||
str = err.Error()
|
||||
} else {
|
||||
for idx, build := range builds {
|
||||
if idx > 10 {
|
||||
break
|
||||
}
|
||||
|
||||
str += fmt.Sprintf(
|
||||
"[%s] %s-%d (%s) [white]%s\n",
|
||||
buildColor(build),
|
||||
build.Reponame,
|
||||
build.BuildNum,
|
||||
build.Branch,
|
||||
build.AuthorName,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return str
|
||||
return title, str, wrap
|
||||
}
|
||||
|
||||
func buildColor(build *Build) string {
|
||||
|
||||
Reference in New Issue
Block a user