From e4d03a19e48ca149320758ba325b8dedb8ad0293 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Sat, 7 Mar 2026 23:52:32 +0000 Subject: [PATCH] Compute in advance all needed assigns in record_set_card Theory is that this makes change tracking easier, and therefore rendering more performant. --- .../live/record_set_live/index.ex | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/music_library_web/live/record_set_live/index.ex b/lib/music_library_web/live/record_set_live/index.ex index 63a42a53..cd6d12b0 100644 --- a/lib/music_library_web/live/record_set_live/index.ex +++ b/lib/music_library_web/live/record_set_live/index.ex @@ -272,6 +272,16 @@ defmodule MusicLibraryWeb.RecordSetLive.Index do attr :list_params, :map, required: true defp record_set_card(assigns) do + assigns = + assigns + |> assign(:html_description, render_description(assigns.record_set.description)) + |> assign( + :patch_params, + assigns.list_params + |> Map.take([:query, :page, :page_size, :order]) + |> Enum.filter(fn {_, v} -> v not in ["", nil] end) + ) + ~H"""
  • - {render_description(@record_set.description)} + {@html_description}
    @@ -311,9 +321,7 @@ defmodule MusicLibraryWeb.RecordSetLive.Index do <.dropdown_link id={"set-actions-#{@record_set.id}-edit"} - patch={ - ~p"/record-sets/#{@record_set}/edit?#{Map.take(@list_params, [:query, :page, :page_size, :order]) |> Enum.filter(fn {_, v} -> v not in ["", nil] end)}" - } + patch={~p"/record-sets/#{@record_set}/edit?#{@patch_params}"} > {gettext("Edit")}