Implement QueueEntry for playlist_nav

This commit is contained in:
aditya-K2
2023-05-19 01:38:47 +05:30
parent 846c7659f0
commit 81e28400f8
3 changed files with 17 additions and 0 deletions

View File

@@ -55,6 +55,7 @@ var (
"playlist_nav": {
"normal": {
{K: tcell.KeyCtrlP}: "play_entry",
{R: 'q'}: "queue_entry",
},
},
"playlist_view": {

View File

@@ -286,6 +286,7 @@ func NewApplication() *tview.Application {
App.SetFocus(Main)
return nil
}, nil),
"queue_entry": NewAction(playlistNav.QueueEntry, nil),
}))
navMenu.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
"open_entry": NewAction(navMenu.OpenEntry,

View File

@@ -83,6 +83,21 @@ func (v *PlaylistNav) PlayEntry(e *tcell.EventKey) *tcell.EventKey {
return nil
}
func (v *PlaylistNav) QueueEntry(e *tcell.EventKey) *tcell.EventKey {
r, _ := v.Table.GetSelection()
playlist := (*v.Playlists)[r]
msg := SendNotificationWithChan("Queueing %s...", playlist.Name)
go func() {
if err := spt.QueuePlaylist(playlist.ID); err != nil {
msg <- err.Error()
return
}
msg <- playlist.Name + " Queued Succesfully!"
}()
return nil
}
func (v *PlaylistNav) RefreshState() {
p, ch := spt.CurrentUserPlaylists()
go func() {