mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-07 21:13:50 -05:00
Implement QueueEntry for artist_view
This commit is contained in:
@@ -93,6 +93,7 @@ var (
|
||||
"artist_view": {
|
||||
"normal": {
|
||||
{K: tcell.KeyCtrlP}: "play_entry",
|
||||
{R: 'q'}: "queue_entry",
|
||||
},
|
||||
},
|
||||
"albums_view": {
|
||||
|
||||
@@ -349,6 +349,10 @@ func NewApplication() *tview.Application {
|
||||
artistView.PlayEntry()
|
||||
return nil
|
||||
}, progressBar),
|
||||
"queue_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
artistView.QueueEntry()
|
||||
return nil
|
||||
}, nil),
|
||||
}))
|
||||
albumsView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
|
||||
"play_entry": 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"
|
||||
)
|
||||
@@ -101,7 +103,22 @@ func (a *ArtistView) OpenEntry() {
|
||||
})
|
||||
}
|
||||
|
||||
func (a *ArtistsView) QueueEntry() {
|
||||
func (a *ArtistView) QueueEntry() {
|
||||
a.handle(func(r int) {
|
||||
msg := SendNotificationWithChan(fmt.Sprintf("Queueing %s...", a.albums[r].Name))
|
||||
go func() {
|
||||
if err := spt.QueueAlbum(a.albums[r].ID); err != nil {
|
||||
msg <- err.Error()
|
||||
}
|
||||
msg <- fmt.Sprintf("%s queued succesfully!", a.albums[r].Name)
|
||||
}()
|
||||
}, func(r int) {
|
||||
msg := fmt.Sprintf("%s queued succesfully!", a.topTracks[r].Name)
|
||||
if err := spt.QueueTracks(a.topTracks[r].ID); err != nil {
|
||||
msg = err.Error()
|
||||
}
|
||||
SendNotification(msg)
|
||||
})
|
||||
}
|
||||
|
||||
func (a *ArtistView) Name() string { return "AlbumsView" }
|
||||
|
||||
Reference in New Issue
Block a user