mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-07 21:13:50 -05:00
Implement QueueSelectedEntry for top_tracks_view
This commit is contained in:
@@ -67,6 +67,7 @@ var (
|
||||
"top_tracks_view": {
|
||||
"normal": {
|
||||
{K: tcell.KeyCtrlP}: "play_entry",
|
||||
{R: 'q'}: "queue_entry",
|
||||
},
|
||||
},
|
||||
"liked_songs_view": {
|
||||
|
||||
@@ -308,6 +308,10 @@ func NewApplication() *tview.Application {
|
||||
topTracksView.PlaySelectedEntry()
|
||||
return nil
|
||||
}, progressBar),
|
||||
"queue_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
topTracksView.QueueSelectedEntry()
|
||||
return nil
|
||||
}, nil),
|
||||
}))
|
||||
likedSongsView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
|
||||
"add_to_playlist": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/aditya-K2/gspt/spt"
|
||||
"github.com/zmb3/spotify/v2"
|
||||
)
|
||||
@@ -94,4 +96,15 @@ func (a *TopTracksView) OpenEntry() {
|
||||
a.handle(trackHandler, artistHandler)
|
||||
}
|
||||
|
||||
func (a *TopTracksView) QueueSelectedEntry() {
|
||||
a.handle(func(r int) {
|
||||
msg := fmt.Sprintf("%s Queued Succesfully!", a.topTracks[r-2-len(a.topArtists)].Name)
|
||||
if err := spt.QueueTracks(a.topTracks[r-2-len(a.topArtists)].ID); err != nil {
|
||||
msg = err.Error()
|
||||
}
|
||||
SendNotification(msg)
|
||||
}, func(int) { SendNotification("Artists can not be queued!") })
|
||||
|
||||
}
|
||||
|
||||
func (a *TopTracksView) Name() string { return "TopTracksView" }
|
||||
|
||||
Reference in New Issue
Block a user