diff --git a/spt/add.go b/spt/add.go index 4622a10..437a9d5 100644 --- a/spt/add.go +++ b/spt/add.go @@ -12,7 +12,7 @@ func AddTracksToPlaylist(playlistId spotify.ID, t ...spotify.ID) error { return err } -func addToQueue(ids ...spotify.SimpleTrack) error { +func QueueTracks(ids ...spotify.SimpleTrack) error { count := 0 _ctx := ctx() for _, v := range ids { @@ -32,7 +32,7 @@ func QueueAlbum(id spotify.ID) error { if err != nil { return err } - if err := addToQueue(*album.Tracks...); err != nil { + if err := QueueTracks(*album.Tracks...); err != nil { return err } return nil diff --git a/spt/get.go b/spt/get.go index 37dc180..9d42377 100644 --- a/spt/get.go +++ b/spt/get.go @@ -305,6 +305,6 @@ func TransferPlayback(deviceId spotify.ID) error { return Client.TransferPlayback(ctx(), deviceId, true) } -func GetFullPlaylist(id *spotify.ID) (*spotify.FullPlaylist, error) { - return Client.GetPlaylist(ctx(), *id) +func GetFullPlaylist(id spotify.ID) (*spotify.FullPlaylist, error) { + return Client.GetPlaylist(ctx(), id) } diff --git a/spt/play.go b/spt/play.go index 9c36f87..51521aa 100644 --- a/spt/play.go +++ b/spt/play.go @@ -17,23 +17,23 @@ func PlaySong(uri spotify.URI) error { }) } -func PlaySongWithContext(context *spotify.URI, position int) error { +func PlaySongWithContext(context spotify.URI, position int) error { return play(&spotify.PlayOptions{ - PlaybackContext: context, + PlaybackContext: &context, PlaybackOffset: &spotify.PlaybackOffset{Position: &position}, }) } -func PlaySongWithContextURI(context, uri *spotify.URI) error { +func PlaySongWithContextURI(context, uri spotify.URI) error { return play(&spotify.PlayOptions{ - PlaybackContext: context, - PlaybackOffset: &spotify.PlaybackOffset{URI: *uri}, + PlaybackContext: &context, + PlaybackOffset: &spotify.PlaybackOffset{URI: uri}, }) } -func PlayContext(context *spotify.URI) error { +func PlayContext(context spotify.URI) error { return play(&spotify.PlayOptions{ - PlaybackContext: context, + PlaybackContext: &context, }) } diff --git a/ui/app.go b/ui/app.go index 92c3843..c924c63 100644 --- a/ui/app.go +++ b/ui/app.go @@ -41,13 +41,11 @@ var ( func onConfigChange() { setStyles() - setBorderRunes() - - if coverArt != nil { + if coverArt != nil && !cfg.HideImage { + SendNotification("HERE") coverArt.RefreshState() } - } func rectWatcher() { @@ -181,7 +179,7 @@ func NewApplication() *tview.Application { SendNotification("Error switching contexts: " + err.Error()) return e } - p, err := spt.GetFullPlaylist(&id) + p, err := spt.GetFullPlaylist(id) if err != nil { SendNotification("Error switching contexts: " + err.Error()) return e @@ -239,7 +237,10 @@ func NewApplication() *tview.Application { }, nil), })) recentlyPlayedView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{ - "open_entry": NewAction(recentlyPlayedView.OpenEntry, + "open_entry": NewAction(func(*tcell.EventKey) *tcell.EventKey { + recentlyPlayedView.OpenEntry() + return nil + }, progressBar), "add_to_playlist": NewAction(func(e *tcell.EventKey) *tcell.EventKey { recentlyPlayedView.AddToPlaylist() @@ -298,7 +299,7 @@ func NewApplication() *tview.Application { })) albumsView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{ "open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey { - albumsView.OpenAlbum() + albumsView.OpenEntry() return nil }, nil), "play_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey { @@ -312,7 +313,7 @@ func NewApplication() *tview.Application { })) albumView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{ "open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey { - albumView.PlayEntry() + albumView.OpenEntry() return nil }, progressBar), "add_to_playlist": NewAction(func(e *tcell.EventKey) *tcell.EventKey { diff --git a/ui/nav.go b/ui/nav.go index b4df812..2efee3c 100644 --- a/ui/nav.go +++ b/ui/nav.go @@ -77,7 +77,7 @@ func NewPlaylistNav() *PlaylistNav { func (v *PlaylistNav) PlayEntry(e *tcell.EventKey) *tcell.EventKey { r, _ := v.Table.GetSelection() - if err := spt.PlayContext(&(*v.Playlists)[r].URI); err != nil { + if err := spt.PlayContext((*v.Playlists)[r].URI); err != nil { SendNotification(err.Error()) } return nil diff --git a/ui/view_album.go b/ui/view_album.go index c91f83c..ce874af 100644 --- a/ui/view_album.go +++ b/ui/view_album.go @@ -74,9 +74,9 @@ func (a *AlbumView) AddToPlaylistVisual(start, end int, e *tcell.EventKey) *tcel return nil } -func (a *AlbumView) PlayEntry() { +func (a *AlbumView) OpenEntry() { r, _ := Main.GetSelection() - if err := spt.PlaySongWithContext(&a.currentFullAlbum.URI, r); err != nil { + if err := spt.PlaySongWithContext(a.currentFullAlbum.URI, r); err != nil { SendNotification(err.Error()) } } diff --git a/ui/view_albums.go b/ui/view_albums.go index f794ef2..65f763d 100644 --- a/ui/view_albums.go +++ b/ui/view_albums.go @@ -46,7 +46,7 @@ func (a *AlbumsView) Content() func() [][]Content { } } -func (a *AlbumsView) OpenAlbum() { +func (a *AlbumsView) OpenEntry() { r, _ := Main.GetSelection() albumView.SetAlbum((*a.savedAlbums)[r].Name, &(*a.savedAlbums)[r].ID) SetCurrentView(albumView) @@ -54,7 +54,7 @@ func (a *AlbumsView) OpenAlbum() { func (a *AlbumsView) PlayEntry() { r, _ := Main.GetSelection() - if err := spt.PlayContext(&(*a.savedAlbums)[r].URI); err != nil { + if err := spt.PlayContext((*a.savedAlbums)[r].URI); err != nil { SendNotification(err.Error()) } } diff --git a/ui/view_artist.go b/ui/view_artist.go index 828f6fd..a959a77 100644 --- a/ui/view_artist.go +++ b/ui/view_artist.go @@ -75,7 +75,7 @@ func (a *ArtistView) PlayEntry() { r, _ := Main.GetSelection() if r > 0 { if r < (len(a.albums) + 1) { - if err := spt.PlayContext(&a.albums[r-1].URI); err != nil { + if err := spt.PlayContext(a.albums[r-1].URI); err != nil { SendNotification(err.Error()) } } diff --git a/ui/view_artists.go b/ui/view_artists.go index 4eab640..b25a7b0 100644 --- a/ui/view_artists.go +++ b/ui/view_artists.go @@ -53,7 +53,7 @@ func (a *ArtistsView) OpenEntry() { func (a *ArtistsView) PlayEntry() { r, _ := Main.GetSelection() - if err := spt.PlayContext(&(*a.followedArtists)[r].URI); err != nil { + if err := spt.PlayContext((*a.followedArtists)[r].URI); err != nil { SendNotification(err.Error()) } } diff --git a/ui/view_playlist.go b/ui/view_playlist.go index 85fc478..113106a 100644 --- a/ui/view_playlist.go +++ b/ui/view_playlist.go @@ -74,7 +74,7 @@ func (p *PlaylistView) AddToPlaylistVisual(start, end int, e *tcell.EventKey) *t func (p *PlaylistView) OpenEntry() { r, _ := Main.GetSelection() - if err := spt.PlaySongWithContext(&p.currentPlaylist.URI, r); err != nil { + if err := spt.PlaySongWithContext(p.currentPlaylist.URI, r); err != nil { SendNotification(err.Error()) } } diff --git a/ui/view_recent.go b/ui/view_recent.go index a30cd83..032c65a 100644 --- a/ui/view_recent.go +++ b/ui/view_recent.go @@ -7,12 +7,6 @@ import ( "github.com/zmb3/spotify/v2" ) -var ( - RecentlyPlayedViewActions = map[string]*Action{ - "selectEntry": NewAction(recentlyPlayedView.OpenEntry, nil), - } -) - type RecentlyPlayedView struct { *DefaultView recentlyPlayed []spotify.RecentlyPlayedItem @@ -65,12 +59,12 @@ func (r *RecentlyPlayedView) RefreshState() { r.recentlyPlayed = _r } -func (re *RecentlyPlayedView) OpenEntry(e *tcell.EventKey) *tcell.EventKey { +func (re *RecentlyPlayedView) OpenEntry() { r, _ := Main.GetSelection() trackUri := re.recentlyPlayed[r].Track.URI contextUri := re.recentlyPlayed[r].PlaybackContext.URI if string(contextUri) != "" { - if err := spt.PlaySongWithContextURI(&contextUri, &trackUri); err != nil { + if err := spt.PlaySongWithContextURI(contextUri, trackUri); err != nil { SendNotification(err.Error()) } } else { @@ -78,5 +72,4 @@ func (re *RecentlyPlayedView) OpenEntry(e *tcell.EventKey) *tcell.EventKey { SendNotification(err.Error()) } } - return nil } diff --git a/ui/view_search.go b/ui/view_search.go index 6b334a4..1a4f271 100644 --- a/ui/view_search.go +++ b/ui/view_search.go @@ -122,7 +122,7 @@ func (a *SearchView) OpenEntry() { } case "playlist": { - if p, err := spt.GetFullPlaylist(&a.searchContent[r].ID); err != nil { + if p, err := spt.GetFullPlaylist(a.searchContent[r].ID); err != nil { SendNotification("Error Opening the playlists: " + err.Error()) return } else { @@ -138,7 +138,7 @@ func (a *SearchView) PlayEntry() { switch a.searchContent[r].Type { case "album", "artist", "playlist": { - if err := spt.PlayContext(&a.searchContent[r].URI); err != nil { + if err := spt.PlayContext(a.searchContent[r].URI); err != nil { SendNotification(err.Error()) } } diff --git a/ui/view_top.go b/ui/view_top.go index 0149edf..1d03c60 100644 --- a/ui/view_top.go +++ b/ui/view_top.go @@ -73,7 +73,7 @@ func (a *TopTracksView) PlaySelectedEntry() { r, _ := Main.GetSelection() if r > 0 { if r < (len(a.topArtists) + 1) { - if err := spt.PlayContext(&a.topArtists[r-1].URI); err != nil { + if err := spt.PlayContext(a.topArtists[r-1].URI); err != nil { SendNotification(err.Error()) } }