generate github state struct

This commit is contained in:
Yuki Osaki 2021-10-31 23:39:01 +09:00
parent d2e75a6359
commit c8de14aa9d
3 changed files with 10 additions and 5 deletions

View file

@ -81,7 +81,7 @@ func (gui *Gui) refreshGithubPullRequests() {
gui.Log.Error(err)
}
gui.State.GithubRecentPRs = prs
gui.State.GithubState.RecentPRs = prs
}
// specific functions

View file

@ -291,7 +291,7 @@ type guiState struct {
CommitFileManager *filetree.CommitFileManager
Submodules []*models.SubmoduleConfig
Branches []*models.Branch
GithubRecentPRs []*models.GithubPullRequest
GithubState *GithubState
Commits []*models.Commit
StashEntries []*models.StashEntry
// Suggestions will sometimes appear when typing into a prompt
@ -346,6 +346,10 @@ type guiState struct {
FilesTrie *patricia.Trie
}
type GithubState struct {
RecentPRs []*models.GithubPullRequest
}
// reuseState determines if we pull the repo state from our repo state map or
// just re-initialize it. For now we're only re-using state when we're going
// in and out of submodules, for the sake of having the cursor back on the submodule
@ -408,7 +412,8 @@ func (gui *Gui) resetState(filterPath string, reuseState bool) {
UserScrolling: false,
},
},
Ptmx: nil,
GithubState: &GithubState{},
Ptmx: nil,
Modes: Modes{
Filtering: filtering.New(filterPath),
CherryPicking: cherrypicking.New(),
@ -732,7 +737,7 @@ func (gui *Gui) setColorScheme() error {
}
func (gui *Gui) GetPr(branch *models.Branch) (*models.GithubPullRequest, bool) {
prs := gui.GitCommand.GenerateGithubPullRequestMap(gui.State.GithubRecentPRs, []*models.Branch{branch})
prs := gui.GitCommand.GenerateGithubPullRequestMap(gui.State.GithubState.RecentPRs, []*models.Branch{branch})
pr, hasPr := prs[branch]
return pr, hasPr

View file

@ -66,7 +66,7 @@ func (gui *Gui) branchesListContext() *ListContext {
OnFocus: gui.handleBranchSelect,
Gui: gui,
GetDisplayStrings: func() [][]string {
prs := gui.GitCommand.GenerateGithubPullRequestMap(gui.State.GithubRecentPRs, gui.State.Branches)
prs := gui.GitCommand.GenerateGithubPullRequestMap(gui.State.GithubState.RecentPRs, gui.State.Branches)
return presentation.GetBranchListDisplayStrings(
gui.State.Branches,