diff --git a/config/key.go b/config/key.go index d080b6c..babe004 100644 --- a/config/key.go +++ b/config/key.go @@ -61,6 +61,7 @@ var ( "playlist_view": { "normal": { {R: 'a'}: "add_to_playlist", + {R: 'q'}: "queue_entry", }, "visual": { {R: 'a'}: "add_to_playlist", diff --git a/ui/app.go b/ui/app.go index fc705a0..0aa90b4 100644 --- a/ui/app.go +++ b/ui/app.go @@ -297,6 +297,10 @@ func NewApplication() *tview.Application { playlistView.AddToPlaylist() return nil }, nil), + "queue_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey { + playlistView.QueueEntry() + return nil + }, nil), })) recentlyPlayedView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{ "add_to_playlist": NewAction(func(e *tcell.EventKey) *tcell.EventKey { diff --git a/ui/view_playlist.go b/ui/view_playlist.go index c931c37..0c3b842 100644 --- a/ui/view_playlist.go +++ b/ui/view_playlist.go @@ -1,6 +1,8 @@ package ui import ( + "fmt" + "github.com/aditya-K2/gspt/spt" "github.com/gdamore/tcell/v2" "github.com/zmb3/spotify/v2" @@ -77,4 +79,14 @@ func (p *PlaylistView) OpenEntry() { } } +func (p *PlaylistView) QueueEntry() { + r, _ := Main.GetSelection() + track := (*(*p.currentUserFullPlaylist).Tracks)[r].Track + msg := fmt.Sprintf("%s Queued Succesfully!", track.Name) + if err := spt.QueueTracks(track.ID); err != nil { + msg = err.Error() + } + SendNotification(msg) +} + func (p *PlaylistView) Name() string { return "PlaylistView" }