Skip to content

Commit

Permalink
Fixed unselected row command
Browse files Browse the repository at this point in the history
Changed sync screen message status
  • Loading branch information
grrlopes committed Aug 26, 2023
1 parent 7219056 commit 88e2d64
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions entity/cmdmodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type CmdModel struct {
Cursor int
Ready bool
Selected string
RowChosen string
Viewport viewport.Model
Start int
End int
Expand Down
8 changes: 4 additions & 4 deletions helper/keymaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package helper
import "github.com/charmbracelet/bubbles/key"

type Keymap struct {
Sync key.Binding
SyncScreen key.Binding
Enter key.Binding
Finder key.Binding
Back key.Binding
Expand All @@ -17,7 +17,7 @@ type Keymap struct {

func (k Keymap) ShortHelp() []key.Binding {
return []key.Binding{
k.Quit, k.Back, k.Enter, k.Sync,
k.Quit, k.Back, k.Enter, k.SyncScreen,
k.Finder, k.PagePrev, k.PageNext,
k.ResetFinder, k.MoveUp, k.MoveDown,
}
Expand All @@ -26,12 +26,12 @@ func (k Keymap) ShortHelp() []key.Binding {
func (k Keymap) FullHelp() [][]key.Binding {
return [][]key.Binding{
{k.Back, k.Enter, k.Quit, k.ResetFinder, k.MoveUp},
{k.Sync, k.Finder, k.PageNext, k.PagePrev, k.MoveDown},
{k.SyncScreen, k.Finder, k.PageNext, k.PagePrev, k.MoveDown},
}
}

var HotKeysHome = Keymap{
Sync: key.NewBinding(
SyncScreen: key.NewBinding(
key.WithKeys("s"),
key.WithHelp("s", "sync"),
),
Expand Down
8 changes: 5 additions & 3 deletions ui/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func NewHome(m *entity.CmdModel) *ModelHome {
txt.Prompt = "Finder: "
h := help.New()
spin := spinner.New()
spin.Spinner = spinner.Jump
spin.Spinner = spinner.Monkey

home := ModelHome{
home: entity.CmdModel{
Expand Down Expand Up @@ -118,6 +118,7 @@ func (m ModelHome) Update(msg tea.Msg) (*ModelHome, tea.Cmd) {
if m.home.Finder.Focused() {
switch {
case key.Matches(msg, helper.HotKeysFinder.Enter):
m.home.RowChosen = m.home.Selected
return &m, tea.Quit
case key.Matches(msg, helper.HotKeysFinder.PageNext):
m.home.Cursor = 0
Expand Down Expand Up @@ -161,12 +162,13 @@ func (m ModelHome) Update(msg tea.Msg) (*ModelHome, tea.Cmd) {
m.home.Content = "arrow"
m.home.Cursor++
}
case key.Matches(msg, helper.HotKeysHome.Sync):
case key.Matches(msg, helper.HotKeysHome.SyncScreen):
m.home.StatusSyncScreen = false
m.home.ActiveSyncScreen = true
m.home.Viewport.SetContent(syncView(&m))
return &m, cmd
case key.Matches(msg, helper.HotKeysHome.Enter):
m.home.RowChosen = m.home.Selected
return &m, tea.Quit
case key.Matches(msg, helper.HotKeysHome.Finder):
m.home.Finder.Focus()
Expand Down Expand Up @@ -225,7 +227,7 @@ func (m ModelHome) View() string {
}

func (m *ModelHome) GetSelected() string {
return m.home.Selected
return m.home.RowChosen
}

func (m *ModelHome) updatepagination() (int, int) {
Expand Down
7 changes: 3 additions & 4 deletions ui/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func syncUpdate(msg tea.Msg, m ModelHome) (*ModelHome, tea.Cmd) {
if m.home.StatusSyncScreen {
choiceEntered = "syncing"
cmds = append(cmds, syncTickCmd())
// cmds = append(cmds, spinJump())
} else {
choiceEntered = "notenter"
}
Expand Down Expand Up @@ -115,16 +114,16 @@ func syncView(m *ModelHome) string {
func syncProgressView(m *ModelHome) string {
switch choiceEntered {
case "syncing":
return fmt.Sprintf("%s Syncing .....", m.home.Spinner.View())
return "Syncing ....."
case "synced":
return "been synced!!!"
return fmt.Sprintf("been synced %s .....", m.home.Spinner.View())
default:
return "Not syncing yet...."
}
}

func syncTickCmd() tea.Cmd {
return tea.Tick(time.Duration(40)*time.Millisecond, func(t time.Time) tea.Msg {
return tea.Tick(time.Duration(180)*time.Millisecond, func(t time.Time) tea.Msg {
return tickMsg(t)
})
}
Expand Down

0 comments on commit 88e2d64

Please sign in to comment.