mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-07 21:13:50 -05:00
Implement QueueSongsVisual for playlist_view
This commit is contained in:
@@ -66,6 +66,7 @@ var (
|
||||
},
|
||||
"visual": {
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
{R: 'q'}: "queue_entry",
|
||||
},
|
||||
},
|
||||
"top_tracks_view": {
|
||||
|
||||
@@ -378,6 +378,7 @@ func NewApplication() *tview.Application {
|
||||
})
|
||||
playlistView.SetVisualActions(map[string]func(start, end int, e *tcell.EventKey) *tcell.EventKey{
|
||||
"add_to_playlist": playlistView.AddToPlaylistVisual,
|
||||
"queue_entry": playlistView.QueueSongsVisual,
|
||||
})
|
||||
likedSongsView.SetVisualActions(map[string]func(start, end int, e *tcell.EventKey) *tcell.EventKey{
|
||||
"add_to_playlist": likedSongsView.AddToPlaylistVisual,
|
||||
|
||||
@@ -72,6 +72,22 @@ func (p *PlaylistView) AddToPlaylistVisual(start, end int, e *tcell.EventKey) *t
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PlaylistView) QueueSongsVisual(start, end int, e *tcell.EventKey) *tcell.EventKey {
|
||||
tracks := (*(*p.currentUserFullPlaylist).Tracks)[start : end+1]
|
||||
msg := SendNotificationWithChan(fmt.Sprintf("Queueing %d tracks...", len(tracks)))
|
||||
go func() {
|
||||
err := spt.QueueTracks(Map(tracks,
|
||||
func(s spotify.PlaylistTrack) spotify.ID {
|
||||
return s.Track.ID
|
||||
})...)
|
||||
if err != nil {
|
||||
msg <- err.Error()
|
||||
}
|
||||
msg <- fmt.Sprintf("Queued %d tracks!", len(tracks))
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PlaylistView) OpenEntry() {
|
||||
r, _ := Main.GetSelection()
|
||||
if err := spt.PlaySongWithContext(p.currentPlaylist.URI, r); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user