Display number of scrobbles when viewing a record
This commit is contained in:
@@ -35,6 +35,7 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
||||
def handle_params(%{"id" => id}, _, socket) do
|
||||
record = Records.get_record!(id)
|
||||
last_listened_track = Records.get_last_listened_track(record)
|
||||
play_count = Records.play_count(record) || 0
|
||||
|
||||
socket =
|
||||
if record.selected_release_id do
|
||||
@@ -48,6 +49,7 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
||||
|> assign(:page_title, page_title(socket.assigns.live_action, record))
|
||||
|> assign(:record, record)
|
||||
|> assign(:last_listened_track, last_listened_track)
|
||||
|> assign(:play_count, play_count)
|
||||
|> assign_similar_records()}
|
||||
end
|
||||
|
||||
|
||||
@@ -321,8 +321,15 @@
|
||||
{gettext("Last listened at")}
|
||||
</dt>
|
||||
<dd class="mt-1 text-xs md:text-sm leading-6 text-zinc-700 dark:text-zinc-300 sm:col-span-2 sm:mt-0">
|
||||
{@last_listened_track &&
|
||||
localize_scrobbled_at(@last_listened_track.scrobbled_at_uts, @timezone)}
|
||||
<span :if={@last_listened_track}>
|
||||
{localize_scrobbled_at(@last_listened_track.scrobbled_at_uts, @timezone)}
|
||||
</span>
|
||||
<span :if={@play_count == 0}>
|
||||
{gettext("Never")}
|
||||
</span>
|
||||
<span :if={@play_count > 0}>
|
||||
{ngettext("(1 scrobble)", "(%{count} scrobbles)", @play_count)}
|
||||
</span>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
Reference in New Issue
Block a user