mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-07 21:13:50 -05:00
Implement QueueSongsVisual for recently_played_view
This commit is contained in:
@@ -18,6 +18,7 @@ var (
|
||||
},
|
||||
"visual": {
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
{R: 'q'}: "queue_entry",
|
||||
},
|
||||
},
|
||||
"search_view": {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user