mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-07 21:13:50 -05:00
Implement QueueEntry for album_view
This commit is contained in:
@@ -104,6 +104,7 @@ var (
|
||||
"album_view": {
|
||||
"normal": {
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
{R: 'q'}: "queue_entry",
|
||||
},
|
||||
"visual": {
|
||||
{R: 'a'}: "add_to_playlist",
|
||||
|
||||
@@ -358,13 +358,17 @@ func NewApplication() *tview.Application {
|
||||
"queue_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
albumsView.QueueEntry()
|
||||
return nil
|
||||
}, progressBar),
|
||||
}, nil),
|
||||
}))
|
||||
albumView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
|
||||
"add_to_playlist": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
albumView.AddToPlaylist()
|
||||
return nil
|
||||
}, nil),
|
||||
"queue_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
albumView.QueueEntry()
|
||||
return nil
|
||||
}, nil),
|
||||
}))
|
||||
|
||||
// Visual Actions
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/aditya-K2/gspt/spt"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/zmb3/spotify/v2"
|
||||
@@ -64,6 +66,16 @@ func (a *AlbumView) AddToPlaylist() {
|
||||
addToPlaylist([]spotify.ID{track.ID})
|
||||
}
|
||||
|
||||
func (a *AlbumView) QueueEntry() {
|
||||
r, _ := Main.GetSelection()
|
||||
track := (*(*a.currentFullAlbum).Tracks)[r]
|
||||
msg := fmt.Sprintf("%s queued succesfully!", track.Name)
|
||||
if err := spt.QueueTracks(track.ID); err != nil {
|
||||
msg = err.Error()
|
||||
}
|
||||
SendNotification(msg)
|
||||
}
|
||||
|
||||
func (a *AlbumView) AddToPlaylistVisual(start, end int, e *tcell.EventKey) *tcell.EventKey {
|
||||
addToPlaylist(Map((*(*a.currentFullAlbum).Tracks)[start:end+1],
|
||||
func(s spotify.SimpleTrack) spotify.ID {
|
||||
|
||||
Reference in New Issue
Block a user