Skip to content

Commit

Permalink
Finder setvalue replace to reset
Browse files Browse the repository at this point in the history
  • Loading branch information
grrlopes committed Aug 2, 2023
1 parent 5a4bd9f commit 2ffcbd4
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions ui/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,17 @@ func (m ModelHome) FooterView() string {
}

func (m ModelHome) Update(msg tea.Msg) (*ModelHome, tea.Cmd) {
var (
cmd tea.Cmd
cmds []tea.Cmd
)

if m.home.ActiveSyncScreen {
m.home.Ready = true
synced, cmd := syncUpdate(msg, m)
return synced, cmd
}

var cmd tea.Cmd
switch msg := msg.(type) {
case tea.KeyMsg:
if m.home.Finder.Focused() {
Expand All @@ -103,16 +107,16 @@ func (m ModelHome) Update(msg tea.Msg) (*ModelHome, tea.Cmd) {
return &m, tea.Quit
}
if msg.String() == "ctrl+c" {
m.home.Finder.SetValue("")
m.home.Finder.Reset()
m.home.Finder.Blur()
}
*m.home.Pagination, cmd = m.home.Pagination.Update(msg)
cmds = append(cmds, cmd)
*m.home.Count = finderCount(m.home.Finder.Value())
start, end := m.updatepagination()
m.home.Start = start
m.home.End = end
m.home.Start, m.home.End = m.updatepagination()
m.home.Store, _ = finderCmd(m.home.Finder.Value(), m.home.Viewport.Height-2, m.home.Start)
m.home.Finder, cmd = m.home.Finder.Update(msg)
cmds = append(cmds, cmd)
} else {
switch msg.String() {
case "ctrl+c", "q":
Expand Down Expand Up @@ -153,13 +157,14 @@ func (m ModelHome) Update(msg tea.Msg) (*ModelHome, tea.Cmd) {

if !m.home.Finder.Focused() {
*m.home.Pagination, cmd = m.home.Pagination.Update(msg)
cmds = append(cmds, cmd)
start, end := m.updatepagination()
m.home.Start = start
m.home.End = end
}

m.home.Viewport.SetContent(m.GetDataView())
return &m, cmd
return &m, tea.Batch(cmds...)
}

func (m ModelHome) View() string {
Expand Down

0 comments on commit 2ffcbd4

Please sign in to comment.