Fix error in rendering an artist with empty bio

Includes a refactor for a helper to test for play count
This commit is contained in:
Claudio Ortolina
2024-12-03 22:26:41 +00:00
parent bef38967a1
commit 2c055acad6
4 changed files with 21 additions and 12 deletions
@@ -50,7 +50,14 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
}
end
defp render_bio(nil), do: gettext("Biography not available")
defp bio_available?(artist_info_result) do
artist_info_result.ok? && artist_info_result.result && artist_info_result.result.bio !== ""
end
defp played?(artist_info_result) do
artist_info_result.ok? && artist_info_result.result &&
artist_info_result.result.play_count > 0
end
# Bios start with text, then a link to read more on Last.fm, followed by a license text.
# We split the bio at the read more link in order to render the license separately.