Add status for each track in the scrobble activity
This commit is contained in:
@@ -20,6 +20,14 @@ defmodule MusicLibraryWeb.StatsLive.Index do
|
||||
|
||||
recent_tracks = LastFm.Feed.all()
|
||||
|
||||
release_ids =
|
||||
recent_tracks
|
||||
|> Enum.map(fn t -> t.album.musicbrainz_id end)
|
||||
|> Enum.uniq()
|
||||
|
||||
collected_release_ids = Collection.collected_release_ids(release_ids)
|
||||
wishlisted_release_ids = Wishlist.wishlisted_release_ids(release_ids)
|
||||
|
||||
if connected?(socket) do
|
||||
LastFm.Feed.subscribe()
|
||||
end
|
||||
@@ -37,6 +45,8 @@ defmodule MusicLibraryWeb.StatsLive.Index do
|
||||
collection_count: collection_count,
|
||||
wishlist_count: wishlist_count,
|
||||
latest_record: latest_record,
|
||||
collected_release_ids: collected_release_ids,
|
||||
wishlisted_release_ids: wishlisted_release_ids,
|
||||
nav_section: :stats
|
||||
)}
|
||||
end
|
||||
|
||||
@@ -100,7 +100,40 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="relative flex-none">
|
||||
<span
|
||||
:if={track.album.musicbrainz_id in @collected_release_ids}
|
||||
class={[
|
||||
"inline-flex items-center rounded-md",
|
||||
"px-2 py-1 text-xs font-medium",
|
||||
"ring-1 ring-inset",
|
||||
"bg-green-50 dark:bg-green-500/10",
|
||||
"text-green-700 dark:text-green-400",
|
||||
"ring-green-600/20 dark:ring-green-500/20"
|
||||
]}
|
||||
>
|
||||
<%= gettext("Collected") %>
|
||||
</span>
|
||||
<span
|
||||
:if={track.album.musicbrainz_id in @wishlisted_release_ids}
|
||||
class={[
|
||||
"inline-flex items-center rounded-md",
|
||||
"px-2 py-1 text-xs font-medium",
|
||||
"ring-1 ring-inset",
|
||||
"bg-yellow-50 dark:bg-yellow-400/10",
|
||||
"text-yellow-800 dark:text-yellow-500",
|
||||
"ring-yellow-600/20 dark:ring-yellow-400/20"
|
||||
]}
|
||||
>
|
||||
<%= gettext("Wishlisted") %>
|
||||
</span>
|
||||
|
||||
<div
|
||||
:if={
|
||||
track.album.musicbrainz_id not in @collected_release_ids and
|
||||
track.album.musicbrainz_id not in @wishlisted_release_ids
|
||||
}
|
||||
class="relative flex-none"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="text-zinc-500 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-300"
|
||||
|
||||
Reference in New Issue
Block a user