Implement QueueEntry for recently_played_view

This commit is contained in:
aditya-K2
2023-05-19 01:20:42 +05:30
parent fc3a19a502
commit 2f85d3f0d1
3 changed files with 17 additions and 0 deletions

View File

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

View File

@@ -302,6 +302,10 @@ func NewApplication() *tview.Application {
recentlyPlayedView.AddToPlaylist()
return nil
}, nil),
"queue_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
recentlyPlayedView.QueueEntry()
return nil
}, nil),
}))
topTracksView.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/aditya-K2/utils"
"github.com/gdamore/tcell/v2"
@@ -73,3 +75,13 @@ func (re *RecentlyPlayedView) OpenEntry() {
}
}
}
func (re *RecentlyPlayedView) QueueEntry() {
r, _ := Main.GetSelection()
track := re.recentlyPlayed[r].Track
msg := fmt.Sprintf("%s Queued Succesfully!", track.Name)
if err := spt.QueueTracks(track.ID); err != nil {
msg = err.Error()
}
SendNotification(msg)
}