Skip to content

Commit

Permalink
fix(ui): quitting on filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Nov 8, 2022
1 parent f45c018 commit 6dbdb43
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions ui/pages/selection/selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/soft-serve/config"
Expand Down Expand Up @@ -88,6 +89,11 @@ func (s *Selection) getMargins() (wm, hm int) {
return
}

// FilterState returns the current filter state.
func (s *Selection) FilterState() list.FilterState {
return s.selector.FilterState()
}

// SetSize implements common.Component.
func (s *Selection) SetSize(width, height int) {
s.common.SetSize(width, height)
Expand Down
15 changes: 12 additions & 3 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ui

import (
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/soft-serve/config"
Expand Down Expand Up @@ -180,9 +181,17 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case key.Matches(msg, ui.common.KeyMap.Help):
cmds = append(cmds, footer.ToggleFooterCmd)
case key.Matches(msg, ui.common.KeyMap.Quit):
// Stop bubblezone background workers.
ui.common.Zone.Close()
return ui, tea.Quit
switch {
case ui.activePage == selectionPage:
if s, ok := ui.pages[selectionPage].(*selection.Selection); ok && s.FilterState() == list.Filtering {
break
}
fallthrough
default:
// Stop bubblezone background workers.
ui.common.Zone.Close()
return ui, tea.Quit
}
case ui.activePage == repoPage && key.Matches(msg, ui.common.KeyMap.Back):
ui.activePage = selectionPage
// Always show the footer on selection page.
Expand Down

0 comments on commit 6dbdb43

Please sign in to comment.