mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-09 22:08:04 -05:00
Implement QueueSongsVisual for recently_played_view
This commit is contained in:
@@ -18,6 +18,7 @@ var (
|
|||||||
},
|
},
|
||||||
"visual": {
|
"visual": {
|
||||||
{R: 'a'}: "add_to_playlist",
|
{R: 'a'}: "add_to_playlist",
|
||||||
|
{R: 'q'}: "queue_entry",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"search_view": {
|
"search_view": {
|
||||||
|
|||||||
@@ -374,6 +374,7 @@ func NewApplication() *tview.Application {
|
|||||||
})
|
})
|
||||||
recentlyPlayedView.SetVisualActions(map[string]func(start, end int, e *tcell.EventKey) *tcell.EventKey{
|
recentlyPlayedView.SetVisualActions(map[string]func(start, end int, e *tcell.EventKey) *tcell.EventKey{
|
||||||
"add_to_playlist": recentlyPlayedView.AddToPlaylistVisual,
|
"add_to_playlist": recentlyPlayedView.AddToPlaylistVisual,
|
||||||
|
"queue_entry": recentlyPlayedView.QueueSongsVisual,
|
||||||
})
|
})
|
||||||
playlistView.SetVisualActions(map[string]func(start, end int, e *tcell.EventKey) *tcell.EventKey{
|
playlistView.SetVisualActions(map[string]func(start, end int, e *tcell.EventKey) *tcell.EventKey{
|
||||||
"add_to_playlist": playlistView.AddToPlaylistVisual,
|
"add_to_playlist": playlistView.AddToPlaylistVisual,
|
||||||
|
|||||||
@@ -49,6 +49,22 @@ func (r *RecentlyPlayedView) AddToPlaylistVisual(start, end int, e *tcell.EventK
|
|||||||
return nil
|
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) Name() string { return "RecentlyPlayedView" }
|
||||||
|
|
||||||
func (r *RecentlyPlayedView) RefreshState() {
|
func (r *RecentlyPlayedView) RefreshState() {
|
||||||
|
|||||||
Reference in New Issue
Block a user