check for no items in library
This commit is contained in:
parent
7ec0ebb83b
commit
ea69ad6310
@ -278,27 +278,35 @@ func MainView(ctx *gctx.Context, client *spotify.Client) ([]list.Item, error) {
|
|||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
items := []list.Item{}
|
items := []list.Item{}
|
||||||
items = append(items, mainItem{
|
if saved_items != nil && saved_items.Total != 0 {
|
||||||
Name: "Saved Tracks",
|
|
||||||
Desc: fmt.Sprintf("%d saved songs", saved_items.Total),
|
|
||||||
SpotifyItem: saved_items,
|
|
||||||
})
|
|
||||||
items = append(items, mainItem{
|
|
||||||
Name: "Albums",
|
|
||||||
Desc: fmt.Sprintf("%d albums", albums.Total),
|
|
||||||
SpotifyItem: albums,
|
|
||||||
})
|
|
||||||
items = append(items, mainItem{
|
|
||||||
Name: "Artists",
|
|
||||||
Desc: fmt.Sprintf("%d artists", artists.Total),
|
|
||||||
SpotifyItem: artists,
|
|
||||||
})
|
|
||||||
for _, playlist := range playlists.Playlists {
|
|
||||||
items = append(items, mainItem{
|
items = append(items, mainItem{
|
||||||
Name: playlist.Name,
|
Name: "Saved Tracks",
|
||||||
Desc: playlist.Description,
|
Desc: fmt.Sprintf("%d saved songs", saved_items.Total),
|
||||||
SpotifyItem: playlist,
|
SpotifyItem: saved_items,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if albums != nil && albums.Total != 0 {
|
||||||
|
items = append(items, mainItem{
|
||||||
|
Name: "Albums",
|
||||||
|
Desc: fmt.Sprintf("%d albums", albums.Total),
|
||||||
|
SpotifyItem: albums,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if artists != nil && artists.Total != 0 {
|
||||||
|
items = append(items, mainItem{
|
||||||
|
Name: "Artists",
|
||||||
|
Desc: fmt.Sprintf("%d artists", artists.Total),
|
||||||
|
SpotifyItem: artists,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if playlists != nil && playlists.Total != 0 {
|
||||||
|
for _, playlist := range playlists.Playlists {
|
||||||
|
items = append(items, mainItem{
|
||||||
|
Name: playlist.Name,
|
||||||
|
Desc: playlist.Description,
|
||||||
|
SpotifyItem: playlist,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user