Skip to content

Commit

Permalink
fix keymap collision when filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
k1nho committed Sep 27, 2023
1 parent c6d334a commit 283e0a7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
28 changes: 18 additions & 10 deletions cmd/show/contributors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion cmd/show/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions pkg/api/constants.go

This file was deleted.

4 changes: 2 additions & 2 deletions pkg/utils/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down

0 comments on commit 283e0a7

Please sign in to comment.