From b81ce0e878974b00ba8f12779cb0ccc1a9c36598 Mon Sep 17 00:00:00 2001 From: abs3nt Date: Sun, 15 Jan 2023 12:35:49 -0800 Subject: [PATCH] now playing --- src/tui/main.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/tui/main.go b/src/tui/main.go index 61cb14b..c8e1852 100644 --- a/src/tui/main.go +++ b/src/tui/main.go @@ -391,7 +391,7 @@ func (m *mainModel) Tick() { select { case <-ticker.C: playing, _ := m.client.PlayerCurrentlyPlaying(m.ctx) - if playing.Playing { + if playing != nil && playing.Playing { currentlyPlaying = "Now playing " + playing.Item.Name + " by " + playing.Item.Artists[0].Name } case <-quit: @@ -537,13 +537,16 @@ func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func InitMain(ctx *gctx.Context, client *spotify.Client, mode Mode) (tea.Model, error) { + var err error lipgloss.SetColorProfile(2) - playing, _ := client.PlayerCurrentlyPlaying(ctx) - if playing.Playing { + playing, err := client.PlayerCurrentlyPlaying(ctx) + if err != nil { + return nil, err + } + if playing != nil && playing.Playing { currentlyPlaying = "Now playing " + playing.Item.Name + " by " + playing.Item.Artists[0].Name } items := []list.Item{} - var err error switch mode { case Main: items, err = MainView(ctx, client)