Implement QueueEntry for liked_songs_view

This commit is contained in:
aditya-K2
2023-05-19 01:25:57 +05:30
parent 42f4216882
commit 846c7659f0
3 changed files with 17 additions and 0 deletions

View File

@@ -74,6 +74,7 @@ var (
"liked_songs_view": {
"normal": {
{R: 'a'}: "add_to_playlist",
{R: 'q'}: "queue_entry",
},
"visual": {
{R: 'a'}: "add_to_playlist",

View File

@@ -322,6 +322,10 @@ func NewApplication() *tview.Application {
likedSongsView.AddToPlaylist()
return nil
}, nil),
"queue_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
likedSongsView.QueueEntry()
return nil
}, nil),
}))
searchView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
"play_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {

View File

@@ -1,6 +1,8 @@
package ui
import (
"fmt"
"github.com/aditya-K2/gspt/spt"
"github.com/gdamore/tcell/v2"
"github.com/zmb3/spotify/v2"
@@ -66,6 +68,16 @@ func (l *LikedSongsView) OpenEntry() {
}
}
func (l *LikedSongsView) QueueEntry() {
r, _ := Main.GetSelection()
track := (*l.likedSongs)[r]
msg := fmt.Sprintf("%s Queued Succesfully!", track.Name)
if err := spt.QueueTracks(track.ID); err != nil {
msg = err.Error()
}
SendNotification(msg)
}
func (l *LikedSongsView) Name() string { return "LikedSongsView" }
func (p *LikedSongsView) refreshState(errHandler func(error)) {