diff --git a/config/key.go b/config/key.go index 8fbf79f..7fbfea5 100644 --- a/config/key.go +++ b/config/key.go @@ -18,6 +18,7 @@ var ( }, "visual": { {R: 'a'}: "add_to_playlist", + {R: 'q'}: "queue_entry", }, }, "search_view": { diff --git a/ui/app.go b/ui/app.go index fcc1866..8ae209d 100644 --- a/ui/app.go +++ b/ui/app.go @@ -374,6 +374,7 @@ func NewApplication() *tview.Application { }) recentlyPlayedView.SetVisualActions(map[string]func(start, end int, e *tcell.EventKey) *tcell.EventKey{ "add_to_playlist": recentlyPlayedView.AddToPlaylistVisual, + "queue_entry": recentlyPlayedView.QueueSongsVisual, }) playlistView.SetVisualActions(map[string]func(start, end int, e *tcell.EventKey) *tcell.EventKey{ "add_to_playlist": playlistView.AddToPlaylistVisual, diff --git a/ui/view_recent.go b/ui/view_recent.go index 5fcd12d..92c2d7a 100644 --- a/ui/view_recent.go +++ b/ui/view_recent.go @@ -49,6 +49,22 @@ func (r *RecentlyPlayedView) AddToPlaylistVisual(start, end int, e *tcell.EventK return nil } +func (r *RecentlyPlayedView) QueueSongsVisual(start, end int, e *tcell.EventKey) *tcell.EventKey { + tracks := r.recentlyPlayed[start : end+1] + msg := SendNotificationWithChan(fmt.Sprintf("Queueing %d tracks...", len(tracks))) + go func() { + err := spt.QueueTracks(Map(tracks, + func(s spotify.RecentlyPlayedItem) spotify.ID { + return s.Track.ID + })...) + if err != nil { + msg <- err.Error() + } + msg <- fmt.Sprintf("Queued %d tracks!", len(tracks)) + }() + return nil +} + func (r *RecentlyPlayedView) Name() string { return "RecentlyPlayedView" } func (r *RecentlyPlayedView) RefreshState() {