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,14 +37,16 @@ func QueueView(ctx *gctx.Context, commands *commands.Commands) ([]list.Item, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
items = append(items, mainItem{
|
if tracks.CurrentlyPlaying.Name != "" {
|
||||||
Name: tracks.CurrentlyPlaying.Name,
|
items = append(items, mainItem{
|
||||||
Artist: tracks.CurrentlyPlaying.Artists[0],
|
Name: tracks.CurrentlyPlaying.Name,
|
||||||
Duration: tracks.CurrentlyPlaying.TimeDuration().Round(time.Second).String(),
|
Artist: tracks.CurrentlyPlaying.Artists[0],
|
||||||
ID: tracks.CurrentlyPlaying.ID,
|
Duration: tracks.CurrentlyPlaying.TimeDuration().Round(time.Second).String(),
|
||||||
Desc: tracks.CurrentlyPlaying.Artists[0].Name + " - " + tracks.CurrentlyPlaying.TimeDuration().Round(time.Second).String(),
|
ID: tracks.CurrentlyPlaying.ID,
|
||||||
SpotifyItem: tracks.CurrentlyPlaying,
|
Desc: tracks.CurrentlyPlaying.Artists[0].Name + " - " + tracks.CurrentlyPlaying.TimeDuration().Round(time.Second).String(),
|
||||||
})
|
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