From c8de14aa9d7b54fbbc88252b21c2a2bc9e654177 Mon Sep 17 00:00:00 2001 From: Yuki Osaki Date: Sun, 31 Oct 2021 23:39:01 +0900 Subject: [PATCH] generate github state struct --- pkg/gui/branches_panel.go | 2 +- pkg/gui/gui.go | 11 ++++++++--- pkg/gui/list_context_config.go | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index 01368704f..879b9d412 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -81,7 +81,7 @@ func (gui *Gui) refreshGithubPullRequests() { gui.Log.Error(err) } - gui.State.GithubRecentPRs = prs + gui.State.GithubState.RecentPRs = prs } // specific functions diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 4d62e08c1..6fdd6c339 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -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 diff --git a/pkg/gui/list_context_config.go b/pkg/gui/list_context_config.go index 90a54cfa4..020a1fa0d 100644 --- a/pkg/gui/list_context_config.go +++ b/pkg/gui/list_context_config.go @@ -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,