mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-08 21:37:58 -05:00
Implement play_entry for search view
This commit is contained in:
@@ -24,6 +24,7 @@ var (
|
||||
},
|
||||
"search_view": {
|
||||
{K: tcell.KeyEnter}: "open_entry",
|
||||
{K: tcell.KeyCtrlP}: "play_entry",
|
||||
},
|
||||
"global": {
|
||||
{R: 'd'}: "choose_device",
|
||||
|
||||
@@ -296,6 +296,10 @@ func NewApplication() *tview.Application {
|
||||
searchView.SelectEntry()
|
||||
return nil
|
||||
}, nil),
|
||||
"play_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
searchView.PlaySelectEntry()
|
||||
return nil
|
||||
}, nil),
|
||||
}))
|
||||
artistsView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
|
||||
"open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
|
||||
@@ -133,6 +133,18 @@ func (a *SearchView) SelectEntry() {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *SearchView) PlaySelectEntry() {
|
||||
r, _ := Main.Table.GetSelection()
|
||||
switch a.searchContent[r].Type {
|
||||
case "album", "artist", "playlist":
|
||||
{
|
||||
if err := spt.PlayContext(&a.searchContent[r].URI); err != nil {
|
||||
SendNotification(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *SearchView) RefreshState() {
|
||||
if a.search != "" {
|
||||
results, err := spt.Search(a.search)
|
||||
|
||||
Reference in New Issue
Block a user