now playing

This commit is contained in:
abs3nt 2023-01-15 12:35:49 -08:00
parent 8325459513
commit b81ce0e878
1 changed files with 7 additions and 4 deletions

View File

@ -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)