From 2b2c242c6f09d7d10288cda13803b6fd636aa158 Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Sun, 15 Apr 2018 00:11:53 -0500 Subject: [PATCH] Fixed: Artist and Album Posters show placeholder instead of image (#292) * Fixed issue where after AlbumPoster had error state, non-errored images would be stuck with placeholder. * Fixed the poster loading issue for artists as well. * Updated ArtistBanner as well. * fixup: banner issues from previous missed update * fixup! remove lazy variable, fix variable --- frontend/src/Album/AlbumCover.js | 23 +++++++++++++++-------- frontend/src/Artist/ArtistBanner.js | 22 ++++++++++------------ frontend/src/Artist/ArtistPoster.js | 6 ++---- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/frontend/src/Album/AlbumCover.js b/frontend/src/Album/AlbumCover.js index a6f63c429..657cc038a 100644 --- a/frontend/src/Album/AlbumCover.js +++ b/frontend/src/Album/AlbumCover.js @@ -58,16 +58,23 @@ class AlbumCover extends Component { pixelRatio } = this.state; - const nextcover = findCover(images); + const nextCover = findCover(images); - if (nextcover && (!cover || nextcover.url !== cover.url)) { + if (nextCover && (!cover || nextCover.url !== cover.url)) { this.setState({ - cover: nextcover, - coverUrl: getCoverUrl(nextcover, pixelRatio * size), - hasError: false - // Don't reset isLoaded, as we want to immediately try to - // show the new image, whether an image was shown previously - // or the placeholder was shown. + cover: nextCover, + coverUrl: getCoverUrl(nextCover, pixelRatio * size), + hasError: false, + isLoaded: true + }); + } + + // The cover could not be loaded.. + if (!nextCover && (this.props !== prevProps)) { + this.setState({ + cover: undefined, + coverUrl: coverPlaceholder, + hasError: true }); } } diff --git a/frontend/src/Artist/ArtistBanner.js b/frontend/src/Artist/ArtistBanner.js index 041130352..eff4ae599 100644 --- a/frontend/src/Artist/ArtistBanner.js +++ b/frontend/src/Artist/ArtistBanner.js @@ -64,20 +64,18 @@ class ArtistBanner extends Component { this.setState({ banner: nextBanner, bannerUrl: getBannerUrl(nextBanner, pixelRatio * size), - hasError: false - // Don't reset isLoaded, as we want to immediately try to - // show the new image, whether an image was shown previously - // or the placeholder was shown. + hasError: false, + isLoaded: true }); + } - // The poster could not be loaded.. - if (!nextBanner && (this.props !== prevProps)) { - this.setState({ - banner: undefined, - bannerUrl: bannerPlaceholder, - hasError: true - }); - } + // The banner could not be loaded.. + if (!nextBanner && (this.props !== prevProps)) { + this.setState({ + banner: undefined, + bannerUrl: bannerPlaceholder, + hasError: true + }); } } diff --git a/frontend/src/Artist/ArtistPoster.js b/frontend/src/Artist/ArtistPoster.js index ca59f750c..55ed9d1d7 100644 --- a/frontend/src/Artist/ArtistPoster.js +++ b/frontend/src/Artist/ArtistPoster.js @@ -64,10 +64,8 @@ class ArtistPoster extends Component { this.setState({ poster: nextPoster, posterUrl: getPosterUrl(nextPoster, pixelRatio * size), - hasError: false - // Don't reset isLoaded, as we want to immediately try to - // show the new image, whether an image was shown previously - // or the placeholder was shown. + hasError: false, + isLoaded: true }); }