From 410538699cafc05b283fb06e09b5da6573b90e67 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Sun, 23 Apr 2023 10:37:43 -0700 Subject: [PATCH] fix #141: don't crash when switching artist page view if invalid artist or page not loaded --- ui/browsing/artistpage.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ui/browsing/artistpage.go b/ui/browsing/artistpage.go index 1bffd04..b584817 100644 --- a/ui/browsing/artistpage.go +++ b/ui/browsing/artistpage.go @@ -167,6 +167,11 @@ func (a *ArtistPage) load() { func (a *ArtistPage) showAlbumGrid() { if a.albumGrid == nil { + if a.artistInfo == nil { + // page not loaded yet or invalid artist + a.activeView = 0 // if page still loading, will show discography view first + return + } a.albumGrid = widgets.NewFixedAlbumGrid(a.artistInfo.Album, a.im, true /*showYear*/) a.albumGrid.OnPlayAlbum = a.onPlayAlbum a.albumGrid.OnShowAlbumPage = a.onShowAlbumPage @@ -177,6 +182,11 @@ func (a *ArtistPage) showAlbumGrid() { func (a *ArtistPage) showTopTracks() { if a.tracklistCtr == nil { + if a.artistInfo == nil { + // page not loaded yet or invalid artist + a.activeView = 1 // if page still loading, will show tracks view first + return + } ts, err := a.sm.Server.GetTopSongs(a.artistInfo.Name, map[string]string{"count": "20"}) if err != nil { log.Printf("error getting top songs: %s", err.Error())