mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-08 21:37:58 -05:00
Implement QueueSongsVisual for liked_songs_view
This commit is contained in:
@@ -82,6 +82,7 @@ var (
|
|||||||
},
|
},
|
||||||
"visual": {
|
"visual": {
|
||||||
{R: 'a'}: "add_to_playlist",
|
{R: 'a'}: "add_to_playlist",
|
||||||
|
{R: 'q'}: "queue_entry",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"artists_view": {
|
"artists_view": {
|
||||||
|
|||||||
@@ -382,6 +382,7 @@ func NewApplication() *tview.Application {
|
|||||||
})
|
})
|
||||||
likedSongsView.SetVisualActions(map[string]func(start, end int, e *tcell.EventKey) *tcell.EventKey{
|
likedSongsView.SetVisualActions(map[string]func(start, end int, e *tcell.EventKey) *tcell.EventKey{
|
||||||
"add_to_playlist": likedSongsView.AddToPlaylistVisual,
|
"add_to_playlist": likedSongsView.AddToPlaylistVisual,
|
||||||
|
"queue_entry": likedSongsView.QueueSongsVisual,
|
||||||
})
|
})
|
||||||
|
|
||||||
mappings := config.GenerateMappings()
|
mappings := config.GenerateMappings()
|
||||||
|
|||||||
@@ -60,6 +60,22 @@ func (l *LikedSongsView) AddToPlaylistVisual(start, end int, e *tcell.EventKey)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *LikedSongsView) QueueSongsVisual(start, end int, e *tcell.EventKey) *tcell.EventKey {
|
||||||
|
tracks := (*l.likedSongs)[start : end+1]
|
||||||
|
msg := SendNotificationWithChan(fmt.Sprintf("Queueing %d tracks...", len(tracks)))
|
||||||
|
go func() {
|
||||||
|
err := spt.QueueTracks(Map(tracks,
|
||||||
|
func(s spotify.SavedTrack) spotify.ID {
|
||||||
|
return s.ID
|
||||||
|
})...)
|
||||||
|
if err != nil {
|
||||||
|
msg <- err.Error()
|
||||||
|
}
|
||||||
|
msg <- fmt.Sprintf("Queued %d tracks!", len(tracks))
|
||||||
|
}()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (l *LikedSongsView) OpenEntry() {
|
func (l *LikedSongsView) OpenEntry() {
|
||||||
r, _ := Main.GetSelection()
|
r, _ := Main.GetSelection()
|
||||||
if err := spt.PlaySong((*l.likedSongs)[r].URI); err != nil {
|
if err := spt.PlaySong((*l.likedSongs)[r].URI); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user