Skip to content

Commit

Permalink
Implement QueueEntry for liked_songs_view
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya-K2 committed May 24, 2023
1 parent 42f4216 commit 846c765
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ var (
"liked_songs_view": {
"normal": {
{R: 'a'}: "add_to_playlist",
{R: 'q'}: "queue_entry",
},
"visual": {
{R: 'a'}: "add_to_playlist",
Expand Down
4 changes: 4 additions & 0 deletions ui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions ui/view_liked.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ui

import (
"fmt"

"github.com/aditya-K2/gspt/spt"
"github.com/gdamore/tcell/v2"
"github.com/zmb3/spotify/v2"
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 846c765

Please sign in to comment.