check for no items in library

This commit is contained in:
abs3nt 2023-01-16 10:14:01 -08:00
parent 7ec0ebb83b
commit ea69ad6310

View File

@ -278,21 +278,28 @@ func MainView(ctx *gctx.Context, client *spotify.Client) ([]list.Item, error) {
wg.Wait()
items := []list.Item{}
if saved_items != nil && saved_items.Total != 0 {
items = append(items, mainItem{
Name: "Saved Tracks",
Desc: fmt.Sprintf("%d saved songs", saved_items.Total),
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,
@ -300,5 +307,6 @@ func MainView(ctx *gctx.Context, client *spotify.Client) ([]list.Item, error) {
SpotifyItem: playlist,
})
}
}
return items, nil
}