fix crash if no queue / not playing anything
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
abs3nt 2023-04-16 00:12:50 -07:00
parent a386f90ec5
commit 6ed3453dae
Signed by: abs3nt
GPG Key ID: FDC6662313FA9386
2 changed files with 11 additions and 9 deletions

View File

@ -547,7 +547,7 @@ func (m *mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
cmd := m.progress.SetPercent(float64(playing.Progress) / float64(playing.Item.Duration))
m.playing = playing
m.playbackContext = playbackContext
if m.mode == Queue {
if m.mode == Queue && len(m.list.Items()) != 0 {
if m.list.Items()[0].(mainItem).SpotifyItem.(spotify.FullTrack).Name != playing.Item.Name {
go func() {
new_items, err := QueueView(m.ctx, m.commands)

View File

@ -37,6 +37,7 @@ func QueueView(ctx *gctx.Context, commands *commands.Commands) ([]list.Item, err
if err != nil {
return nil, err
}
if tracks.CurrentlyPlaying.Name != "" {
items = append(items, mainItem{
Name: tracks.CurrentlyPlaying.Name,
Artist: tracks.CurrentlyPlaying.Artists[0],
@ -45,6 +46,7 @@ func QueueView(ctx *gctx.Context, commands *commands.Commands) ([]list.Item, err
Desc: tracks.CurrentlyPlaying.Artists[0].Name + " - " + tracks.CurrentlyPlaying.TimeDuration().Round(time.Second).String(),
SpotifyItem: tracks.CurrentlyPlaying,
})
}
for _, track := range tracks.Items {
items = append(items, mainItem{
Name: track.Name,