Skip to content

Commit

Permalink
fix: user interactions in search page with no results resulting in NP…
Browse files Browse the repository at this point in the history
…E. (#79)
  • Loading branch information
xxxserxxx authored Oct 28, 2024
1 parent 18c3f9b commit 3ea5da2
Showing 1 changed file with 40 additions and 22 deletions.
62 changes: 40 additions & 22 deletions page_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,23 @@ func (ui *Ui) createSearchPage() *SearchPage {
ui.app.SetFocus(searchPage.albumList)
return nil
case tcell.KeyEnter:
idx := searchPage.artistList.GetCurrentItem()
searchPage.addArtistToQueue(searchPage.artists[idx])
return nil
if len(searchPage.artists) != 0 {
idx := searchPage.artistList.GetCurrentItem()
searchPage.addArtistToQueue(searchPage.artists[idx])
return nil
}
return event
}

switch event.Rune() {
case 'a':
idx := searchPage.artistList.GetCurrentItem()
searchPage.logger.Printf("artistList adding (%d) %s", idx, searchPage.artists[idx].Name)
searchPage.addArtistToQueue(searchPage.artists[idx])
return nil
if len(searchPage.artists) != 0 {
idx := searchPage.artistList.GetCurrentItem()
searchPage.logger.Printf("artistList adding (%d) %s", idx, searchPage.artists[idx].Name)
searchPage.addArtistToQueue(searchPage.artists[idx])
return nil
}
return event
case '/':
searchPage.ui.app.SetFocus(searchPage.searchField)
return nil
Expand All @@ -122,17 +128,23 @@ func (ui *Ui) createSearchPage() *SearchPage {
ui.app.SetFocus(searchPage.songList)
return nil
case tcell.KeyEnter:
idx := searchPage.albumList.GetCurrentItem()
searchPage.addAlbumToQueue(searchPage.albums[idx])
return nil
if len(searchPage.albums) != 0 {
idx := searchPage.albumList.GetCurrentItem()
searchPage.addAlbumToQueue(searchPage.albums[idx])
return nil
}
return event
}

switch event.Rune() {
case 'a':
idx := searchPage.albumList.GetCurrentItem()
searchPage.logger.Printf("albumList adding (%d) %s", idx, searchPage.albums[idx].Name)
searchPage.addAlbumToQueue(searchPage.albums[idx])
return nil
if len(searchPage.albums) != 0 {
idx := searchPage.albumList.GetCurrentItem()
searchPage.logger.Printf("albumList adding (%d) %s", idx, searchPage.albums[idx].Name)
searchPage.addAlbumToQueue(searchPage.albums[idx])
return nil
}
return event
case '/':
searchPage.ui.app.SetFocus(searchPage.searchField)
return nil
Expand All @@ -152,18 +164,24 @@ func (ui *Ui) createSearchPage() *SearchPage {
ui.app.SetFocus(searchPage.artistList)
return nil
case tcell.KeyEnter:
idx := searchPage.songList.GetCurrentItem()
ui.addSongToQueue(searchPage.songs[idx])
ui.queuePage.UpdateQueue()
return nil
if len(searchPage.artists) != 0 {
idx := searchPage.songList.GetCurrentItem()
ui.addSongToQueue(searchPage.songs[idx])
ui.queuePage.UpdateQueue()
return nil
}
return event
}

switch event.Rune() {
case 'a':
idx := searchPage.songList.GetCurrentItem()
ui.addSongToQueue(searchPage.songs[idx])
ui.queuePage.updateQueue()
return nil
if len(searchPage.artists) != 0 {
idx := searchPage.songList.GetCurrentItem()
ui.addSongToQueue(searchPage.songs[idx])
ui.queuePage.updateQueue()
return nil
}
return event
case '/':
searchPage.ui.app.SetFocus(searchPage.searchField)
return nil
Expand Down

0 comments on commit 3ea5da2

Please sign in to comment.