From 3dc69a5a10ccfad689216d2ec1de8154f4d80cab Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Mon, 18 Aug 2025 10:12:43 +0300 Subject: [PATCH] Auto-refresh top albums and artists when new scrobbles come in --- lib/music_library_web/live/stats_live/index.ex | 6 ++++++ lib/music_library_web/live/stats_live/index.html.heex | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/music_library_web/live/stats_live/index.ex b/lib/music_library_web/live/stats_live/index.ex index b541e605..3399b099 100644 --- a/lib/music_library_web/live/stats_live/index.ex +++ b/lib/music_library_web/live/stats_live/index.ex @@ -116,7 +116,13 @@ defmodule MusicLibraryWeb.StatsLive.Index do artist_ids: artist_ids } = ScrobbleActivity.from_recent_tracks(recent_tracks, socket.assigns.timezone) + last_updated_uts = + if track = List.first(localized_recent_tracks) do + track.scrobbled_at_uts + end + socket + |> assign(:last_updated_uts, last_updated_uts) |> stream(:recent_tracks, localized_recent_tracks, reset: true) |> stream(:recent_albums, recent_albums, reset: true) |> assign( diff --git a/lib/music_library_web/live/stats_live/index.html.heex b/lib/music_library_web/live/stats_live/index.html.heex index 846a9fbc..9a553f93 100644 --- a/lib/music_library_web/live/stats_live/index.html.heex +++ b/lib/music_library_web/live/stats_live/index.html.heex @@ -70,8 +70,8 @@
- - + +