From 283e0a76d43217d163319d62293a0cf82614cc78 Mon Sep 17 00:00:00 2001 From: k1nho Date: Tue, 26 Sep 2023 23:21:02 -0400 Subject: [PATCH] fix keymap collision when filtering --- cmd/show/contributors.go | 28 ++++++++++++++++++---------- cmd/show/show.go | 3 ++- pkg/api/constants.go | 6 ------ pkg/utils/github.go | 4 ++-- 4 files changed, 22 insertions(+), 19 deletions(-) delete mode 100644 pkg/api/constants.go diff --git a/cmd/show/contributors.go b/cmd/show/contributors.go index 03103f9..5872940 100644 --- a/cmd/show/contributors.go +++ b/cmd/show/contributors.go @@ -101,21 +101,28 @@ func (m ContributorModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.KeyMsg: switch msg.String() { case "B": - return m, func() tea.Msg { return BackMsg{} } + if !m.prList.SettingFilter() { + return m, func() tea.Msg { return BackMsg{} } + } case "H": - m.prList.SetShowHelp(!m.prList.ShowHelp()) - return m, nil + if !m.prList.SettingFilter() { + m.prList.SetShowHelp(!m.prList.ShowHelp()) + return m, nil + } case "O": - pr, ok := m.prList.SelectedItem().(prItem) - if ok { - err := browser.OpenURL(fmt.Sprintf("https://github.com/%s/pull/%d", pr.GetRepoName(), pr.Number)) - if err != nil { - fmt.Println("could not open pull request in browser") + if !m.prList.SettingFilter() { + pr, ok := m.prList.SelectedItem().(prItem) + if ok { + err := browser.OpenURL(fmt.Sprintf("https://github.com/%s/pull/%d", pr.GetRepoName(), pr.Number)) + if err != nil { + fmt.Println("could not open pull request in browser") + } } } case "q", "ctrl+c", "ctrl+d": - return m, tea.Quit - + if !m.prList.SettingFilter() { + return m, tea.Quit + } } } m.prList, cmd = m.prList.Update(msg) @@ -202,6 +209,7 @@ func (m *ContributorModel) fetchContributorPRs(name string) error { l.Title = "✨ Latest Pull Requests" l.Styles.Title = ListItemTitleStyle l.Styles.HelpStyle = HelpStyle + l.Styles.NoItems = ItemStyle l.SetShowStatusBar(false) l.SetStatusBarItemName("pull request", "pull requests") l.AdditionalShortHelpKeys = func() []key.Binding { diff --git a/cmd/show/show.go b/cmd/show/show.go index 662b268..9ab79e0 100644 --- a/cmd/show/show.go +++ b/cmd/show/show.go @@ -8,6 +8,7 @@ import ( client "github.com/open-sauced/go-api/client" "github.com/open-sauced/pizza-cli/pkg/api" + "github.com/open-sauced/pizza-cli/pkg/constants" "github.com/open-sauced/pizza-cli/pkg/utils" "github.com/spf13/cobra" ) @@ -72,7 +73,7 @@ func NewShowCommand() *cobra.Command { useBeta, _ := cmd.Flags().GetBool("beta") if useBeta { - endpoint = api.BetaAPIEndpoint + endpoint = constants.EndpointBeta } opts.APIClient = api.NewGoClient(endpoint) diff --git a/pkg/api/constants.go b/pkg/api/constants.go deleted file mode 100644 index 5f4a0d0..0000000 --- a/pkg/api/constants.go +++ /dev/null @@ -1,6 +0,0 @@ -package api - -const ( - APIEndpoint = "https://api.opensauced.pizza" - BetaAPIEndpoint = "https://beta.api.opensauced.pizza" -) diff --git a/pkg/utils/github.go b/pkg/utils/github.go index 68be868..05dbcb2 100644 --- a/pkg/utils/github.go +++ b/pkg/utils/github.go @@ -16,7 +16,7 @@ func GetOwnerAndRepoFromURL(input string) (owner, repo string, err error) { path := strings.Trim(u.Path, "/") parts := strings.Split(path, "/") if len(parts) != 2 { - return "", "", fmt.Errorf("Invalid URL: %s", input) + return "", "", fmt.Errorf("invalid URL: %s", input) } repoOwner = parts[0] repoName = parts[1] @@ -26,7 +26,7 @@ func GetOwnerAndRepoFromURL(input string) (owner, repo string, err error) { // check (owner/repo) format parts := strings.Split(input, "/") if len(parts) != 2 { - return "", "", fmt.Errorf("Invalid URL: %s", input) + return "", "", fmt.Errorf("invalid URL: %s", input) } repoOwner = parts[0] repoName = parts[1]