Display badge when an artist is touring

This commit is contained in:
Claudio Ortolina
2025-01-25 08:50:46 +00:00
parent 916a934da6
commit 0d77fdc031
4 changed files with 18 additions and 9 deletions
+5 -3
View File
@@ -1,13 +1,14 @@
defmodule LastFm.Artist do
@enforce_keys [:musicbrainz_id, :name]
defstruct [:musicbrainz_id, :name, :bio, :image, :play_count]
defstruct [:musicbrainz_id, :name, :bio, :image, :play_count, :on_tour]
@type t :: %__MODULE__{
musicbrainz_id: String.t(),
name: String.t(),
bio: String.t(),
image: String.t(),
play_count: non_neg_integer()
play_count: non_neg_integer(),
on_tour: boolean()
}
def from_api_response(api_response) do
@@ -16,7 +17,8 @@ defmodule LastFm.Artist do
name: api_response["name"],
bio: api_response["bio"]["content"] || "",
image: get_image(api_response),
play_count: get_play_count(api_response)
play_count: get_play_count(api_response),
on_tour: api_response["ontour"] == "1"
}
end
@@ -28,6 +28,7 @@
<span class="sr-only">
{gettext("Number of scrobbles")}
</span>
<.round_badge :if={artist_info.on_tour} text={gettext("On Tour")} />
<.round_badge text={artist_info.play_count} />
</span>
</.async_result>