Skip to content

Commit

Permalink
Add improved documentation about search page; Changes search page foc…
Browse files Browse the repository at this point in the history
…us defaults; Fixes error handling bug in playlists page; Fixes incorrect search help text.
  • Loading branch information
xxxserxxx committed Oct 15, 2024
1 parent 2e762f2 commit 91d15d4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 26 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ The default is `▉▊▋▌▍▎▏▎▍▌▋▊▉`. Set only one of these

### Search Controls

The search tab performs a server-side search for text in metadata name fields.
The search page performs a server-side search for text in IDv3 metadata fields.
The search results are filtered into three columns: artist, album, and song. 20
results (in each column) are fetched at a time; use `n` to load more results.

Expand All @@ -163,6 +163,8 @@ In the search field:
- `Enter`: Perform the query.
- `Escape`: Escapes into the columns, where the global key bindings work.

Note that the Search page is *not* a browser like the Browser page: it displays the search results returned by the server. Selecting a different artist will not change the album or song search results. OpenSubsonic servers implement the search function differently; in gonic, if you search for "black", you will get artists with "black" in their names in the artists column; albums with "black" in their titles in the albums column; and songs with "black" in their titles in the songs column. Navidrome appears to include all results with "black" anywhere in their IDv3 metadata. Since the API search results filteres these matches into sections -- artists, albums, and songs -- this means that, with Navidrome, you may see albums that don't have "black" in their names; maybe "black" is in their artist title.

## Advanced Configuration and Features

### MPRIS2 Integration
Expand Down
14 changes: 9 additions & 5 deletions help_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ a add playlist or song to queue
`

const helpSearchPage = `
artist, album, or song tab
Down focus search field
artist, album, or song column
Down/Up navigate within the column
Left previous column
Right next column
Enter recursively add item to quue
a recursively add item to quue
/ start search
Enter/a recursively add item to quue
/ start search (20 results per)
n load more results
search field
Enter search for text
Esc cancel search
Note: unlike browser, columns navigate
search results, not selected items.
`
3 changes: 3 additions & 0 deletions page_playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ func (p *PlaylistPage) UpdatePlaylists() {
response, err := p.ui.connection.GetPlaylists()
if err != nil {
p.logger.PrintError("GetPlaylists", err)
p.isUpdating = false
stop <- true
return
}
p.updatingMutex.Lock()
defer p.updatingMutex.Unlock()
Expand Down
41 changes: 21 additions & 20 deletions page_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,19 @@ func (ui *Ui) createSearchPage() *SearchPage {
// search bar
searchPage.searchField = tview.NewInputField().
SetLabel("search:").
SetFieldBackgroundColor(tcell.ColorBlack)
SetFieldBackgroundColor(tcell.ColorBlack).
SetDoneFunc(func(key tcell.Key) {
searchPage.aproposFocus()
})

searchPage.columnsFlex = tview.NewFlex().SetDirection(tview.FlexColumn).
AddItem(searchPage.artistList, 0, 1, false).
AddItem(searchPage.artistList, 0, 1, true).
AddItem(searchPage.albumList, 0, 1, false).
AddItem(searchPage.songList, 0, 1, false)

searchPage.Root = tview.NewFlex().SetDirection(tview.FlexRow).
AddItem(searchPage.columnsFlex, 0, 1, false).
AddItem(searchPage.searchField, 1, 1, true)
AddItem(searchPage.columnsFlex, 0, 1, true).
AddItem(searchPage.searchField, 1, 1, false)

searchPage.artistList.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
switch event.Key() {
Expand Down Expand Up @@ -174,15 +177,7 @@ func (ui *Ui) createSearchPage() *SearchPage {
searchPage.searchField.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
switch event.Key() {
case tcell.KeyUp, tcell.KeyESC:
if len(searchPage.artists) != 0 {
ui.app.SetFocus(searchPage.artistList)
} else if len(searchPage.albums) != 0 {
ui.app.SetFocus(searchPage.albumList)
} else if len(searchPage.songs) != 0 {
ui.app.SetFocus(searchPage.songList)
} else {
ui.app.SetFocus(searchPage.artistList)
}
searchPage.aproposFocus()
case tcell.KeyEnter:
searchPage.artistList.Clear()
searchPage.artists = make([]*subsonic.Artist, 0)
Expand All @@ -195,13 +190,7 @@ func (ui *Ui) createSearchPage() *SearchPage {
searchPage.albumOffset = 0
searchPage.songOffset = 0
searchPage.search()
if len(searchPage.artists) > 0 {
ui.app.SetFocus(searchPage.artistList)
} else if len(searchPage.albums) > 0 {
ui.app.SetFocus(searchPage.albumList)
} else if len(searchPage.songs) > 0 {
ui.app.SetFocus(searchPage.songList)
}
searchPage.aproposFocus()
default:
return event
}
Expand Down Expand Up @@ -293,3 +282,15 @@ func (s *SearchPage) addAlbumToQueue(entity subsonic.Ider) {
}
s.ui.queuePage.UpdateQueue()
}

func (s *SearchPage) aproposFocus() {
if len(s.artists) != 0 {
s.ui.app.SetFocus(s.artistList)
} else if len(s.albums) != 0 {
s.ui.app.SetFocus(s.albumList)
} else if len(s.songs) != 0 {
s.ui.app.SetFocus(s.songList)
} else {
s.ui.app.SetFocus(s.artistList)
}
}

0 comments on commit 91d15d4

Please sign in to comment.