mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
appending to a slice and referencing items within that using the currently selected
This commit is contained in:
parent
cbae7449b0
commit
c21b7c32a8
@ -22,6 +22,7 @@ func (widget *Widget) content() (string, string, bool) {
|
||||
}
|
||||
|
||||
// initial maxItems count
|
||||
widget.Items = make([]int, 0)
|
||||
widget.SetItemCount(len(repo.myReviewRequests((username))))
|
||||
|
||||
title := fmt.Sprintf("%s - %s", widget.CommonSettings().Title, widget.title(repo))
|
||||
@ -60,6 +61,7 @@ func (widget *Widget) displayMyPullRequests(repo *GithubRepo, username string) s
|
||||
for idx, pr := range prs {
|
||||
str += fmt.Sprintf(` %s[green]["%d"]%4d[""][white] %s`, widget.mergeString(pr), maxItems + idx, *pr.Number, *pr.Title)
|
||||
str += "\n"
|
||||
widget.Items = append(widget.Items, *pr.Number)
|
||||
}
|
||||
|
||||
widget.SetItemCount(maxItems + prLength)
|
||||
@ -86,6 +88,7 @@ func (widget *Widget) displayCustomQuery(repo *GithubRepo, filter string, perPag
|
||||
for idx, issue := range res.Issues {
|
||||
str += fmt.Sprintf(` [green]["%d"]%4d[""][white] %s`, maxItems + idx , *issue.Number, *issue.Title)
|
||||
str += "\n"
|
||||
widget.Items = append(widget.Items, *issue.Number)
|
||||
}
|
||||
|
||||
widget.SetItemCount(maxItems + issuesLength)
|
||||
@ -104,6 +107,7 @@ func (widget *Widget) displayMyReviewRequests(repo *GithubRepo, username string)
|
||||
for idx, pr := range prs {
|
||||
str += fmt.Sprintf(` [green]["%d"]%4d[""][white] %s`, idx, *pr.Number, *pr.Title)
|
||||
str += "\n"
|
||||
widget.Items = append(widget.Items, *pr.Number)
|
||||
}
|
||||
|
||||
return str
|
||||
|
@ -19,6 +19,7 @@ type Widget struct {
|
||||
settings *Settings
|
||||
Selected int
|
||||
maxItems int
|
||||
Items []int
|
||||
}
|
||||
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
@ -132,7 +133,7 @@ func (widget *Widget) currentGithubRepo() *GithubRepo {
|
||||
func (widget *Widget) openPr() {
|
||||
currentSelection := widget.View.GetHighlights()
|
||||
if widget.Selected >= 0 && currentSelection[0] != "" {
|
||||
url := (*widget.currentGithubRepo().RemoteRepo.HTMLURL + "/pull/" + widget.View.GetRegionText(currentSelection[0]))
|
||||
url := (*widget.currentGithubRepo().RemoteRepo.HTMLURL + "/pull/" + strconv.Itoa(widget.Items[widget.Selected]))
|
||||
utils.OpenFile(url)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user