automatically select last added
This commit is contained in:
parent
06df0d4459
commit
f9e5c0bace
|
@ -86,7 +86,7 @@ func (m tabEMDB) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
case Movies:
|
case Movies:
|
||||||
m.logger.Log(fmt.Sprintf("found %d movies in in emdb", len(msg)))
|
m.logger.Log(fmt.Sprintf("found %d movies in in emdb", len(msg)))
|
||||||
m.list.SetItems(msg.listItems())
|
m.list.SetItems(msg.listItems())
|
||||||
m.list.Select(0)
|
m.list.Select(len(msg.listItems()) - 1)
|
||||||
m.UpdateForm()
|
m.UpdateForm()
|
||||||
m.list, cmd = m.list.Update(msg)
|
m.list, cmd = m.list.Update(msg)
|
||||||
cmds = append(cmds, cmd)
|
cmds = append(cmds, cmd)
|
||||||
|
@ -153,7 +153,6 @@ func (m *tabEMDB) UpdateForm() {
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.Log(fmt.Sprintf("updating form with movie %s", movie.m.Title))
|
|
||||||
m.formInputs[0].SetValue(movie.m.WatchedOn)
|
m.formInputs[0].SetValue(movie.m.WatchedOn)
|
||||||
m.formInputs[1].SetValue(fmt.Sprintf("%d", movie.m.Rating))
|
m.formInputs[1].SetValue(fmt.Sprintf("%d", movie.m.Rating))
|
||||||
m.formInputs[2].SetValue(movie.m.Comment)
|
m.formInputs[2].SetValue(movie.m.Comment)
|
||||||
|
|
|
@ -51,12 +51,16 @@ func (m tabTMDB) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
m.focused = "search"
|
m.focused = "search"
|
||||||
case tea.KeyMsg:
|
case tea.KeyMsg:
|
||||||
switch msg.String() {
|
switch msg.String() {
|
||||||
case "ctrl+c", "q", "esc":
|
case "ctrl+c", "esc":
|
||||||
return m, tea.Quit
|
return m, tea.Quit
|
||||||
|
case "q":
|
||||||
|
if m.focused == "result" {
|
||||||
|
return m, tea.Quit
|
||||||
|
}
|
||||||
case "right", "tab":
|
case "right", "tab":
|
||||||
cmds = append(cmds, SelectNextTab())
|
cmds = append(cmds, SelectNextTab(), m.ResetCmd())
|
||||||
case "left", "shift+tab":
|
case "left", "shift+tab":
|
||||||
cmds = append(cmds, SelectPrevTab())
|
cmds = append(cmds, SelectPrevTab(), m.ResetCmd())
|
||||||
case "enter":
|
case "enter":
|
||||||
switch m.focused {
|
switch m.focused {
|
||||||
case "search":
|
case "search":
|
||||||
|
|
Loading…
Reference in New Issue