fix crash if no queue / not playing anything
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
a386f90ec5
commit
6ed3453dae
@ -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))
|
cmd := m.progress.SetPercent(float64(playing.Progress) / float64(playing.Item.Duration))
|
||||||
m.playing = playing
|
m.playing = playing
|
||||||
m.playbackContext = playbackContext
|
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 {
|
if m.list.Items()[0].(mainItem).SpotifyItem.(spotify.FullTrack).Name != playing.Item.Name {
|
||||||
go func() {
|
go func() {
|
||||||
new_items, err := QueueView(m.ctx, m.commands)
|
new_items, err := QueueView(m.ctx, m.commands)
|
||||||
|
@ -37,6 +37,7 @@ func QueueView(ctx *gctx.Context, commands *commands.Commands) ([]list.Item, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if tracks.CurrentlyPlaying.Name != "" {
|
||||||
items = append(items, mainItem{
|
items = append(items, mainItem{
|
||||||
Name: tracks.CurrentlyPlaying.Name,
|
Name: tracks.CurrentlyPlaying.Name,
|
||||||
Artist: tracks.CurrentlyPlaying.Artists[0],
|
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(),
|
Desc: tracks.CurrentlyPlaying.Artists[0].Name + " - " + tracks.CurrentlyPlaying.TimeDuration().Round(time.Second).String(),
|
||||||
SpotifyItem: tracks.CurrentlyPlaying,
|
SpotifyItem: tracks.CurrentlyPlaying,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
for _, track := range tracks.Items {
|
for _, track := range tracks.Items {
|
||||||
items = append(items, mainItem{
|
items = append(items, mainItem{
|
||||||
Name: track.Name,
|
Name: track.Name,
|
||||||
|
Loading…
Reference in New Issue
Block a user