Extract apply_fallback_index to shared helper

Closes #92
This commit is contained in:
Claudio Ortolina
2026-03-05 19:50:50 +00:00
parent d4376e5fa0
commit 6d72df3905
6 changed files with 19 additions and 56 deletions
@@ -232,7 +232,7 @@ defmodule MusicLibraryWeb.ScrobbledTracksLive.Index do
track = ScrobbleActivity.get_track!(id)
socket
|> apply_fallback_index(params)
|> apply_fallback_index(params, :tracks, &apply_action/3)
|> assign(:page_title, gettext("Edit Track"))
|> assign(:track, track)
|> assign(:form, to_form(Track.changeset(track, %{})))
@@ -252,15 +252,6 @@ defmodule MusicLibraryWeb.ScrobbledTracksLive.Index do
load_and_assign_tracks(socket, track_list_params)
end
def apply_fallback_index(socket, params) do
if get_in(socket.assigns, [:streams, :tracks]) == nil do
socket
|> apply_action(:index, params)
else
socket
end
end
@impl true
def handle_info({MusicLibraryWeb.ScrobbledTracksLive.Form, {:saved, _track}}, socket) do
{:noreply, load_and_assign_tracks(socket, socket.assigns.track_list_params)}