From 2f85d3f0d1be9722e1c13cd387e142c866636760 Mon Sep 17 00:00:00 2001 From: aditya-K2 Date: Fri, 19 May 2023 01:20:42 +0530 Subject: [PATCH] Implement QueueEntry for recently_played_view --- config/key.go | 1 + ui/app.go | 4 ++++ ui/view_recent.go | 12 ++++++++++++ 3 files changed, 17 insertions(+) diff --git a/config/key.go b/config/key.go index 1a37113..12e37b2 100644 --- a/config/key.go +++ b/config/key.go @@ -14,6 +14,7 @@ var ( "recently_played_view": { "normal": { {R: 'a'}: "add_to_playlist", + {R: 'q'}: "queue_entry", }, "visual": { {R: 'a'}: "add_to_playlist", diff --git a/ui/app.go b/ui/app.go index 0d544b7..ea8d257 100644 --- a/ui/app.go +++ b/ui/app.go @@ -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 { diff --git a/ui/view_recent.go b/ui/view_recent.go index 024a576..a298a0e 100644 --- a/ui/view_recent.go +++ b/ui/view_recent.go @@ -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) +}