diff --git a/config/key.go b/config/key.go index 3f3666f..069b02d 100644 --- a/config/key.go +++ b/config/key.go @@ -104,6 +104,7 @@ var ( "album_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 cb37032..190a61e 100644 --- a/ui/app.go +++ b/ui/app.go @@ -358,13 +358,17 @@ func NewApplication() *tview.Application { "queue_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey { albumsView.QueueEntry() return nil - }, progressBar), + }, nil), })) albumView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{ "add_to_playlist": NewAction(func(e *tcell.EventKey) *tcell.EventKey { albumView.AddToPlaylist() return nil }, nil), + "queue_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey { + albumView.QueueEntry() + return nil + }, nil), })) // Visual Actions diff --git a/ui/view_album.go b/ui/view_album.go index d02f3fe..a6dc2d4 100644 --- a/ui/view_album.go +++ b/ui/view_album.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" @@ -64,6 +66,16 @@ func (a *AlbumView) AddToPlaylist() { addToPlaylist([]spotify.ID{track.ID}) } +func (a *AlbumView) QueueEntry() { + r, _ := Main.GetSelection() + track := (*(*a.currentFullAlbum).Tracks)[r] + msg := fmt.Sprintf("%s queued succesfully!", track.Name) + if err := spt.QueueTracks(track.ID); err != nil { + msg = err.Error() + } + SendNotification(msg) +} + func (a *AlbumView) AddToPlaylistVisual(start, end int, e *tcell.EventKey) *tcell.EventKey { addToPlaylist(Map((*(*a.currentFullAlbum).Tracks)[start:end+1], func(s spotify.SimpleTrack) spotify.ID {