Out of curiosity, I updated my live_view from 0.19.5 to the current 0.20.0 and quickly realized that my patch on my <.link> is not re-rendering/updating my live view.
<.link
patch={
~p"/budgets?#{%{@options | sort_by: @sort_by, sort_order: next_sort_order(@options.sort_order)}}"
}
>
<%= render_slot(@inner_block) %>
<%= sort_indicator(@sort_by, @options) %>
</.link>
I quickly checked with IO.inspect inside my handle_params to see if my options (and my budgets) were changing, and they were.
here’s my handle_params
def handle_params(params, _uri, socket) do
current_user = socket.assigns.current_user
sort_by = valid_sort_by(params)
sort_order = valid_sort_order(params)
page = param_to_integer(params["page"], 1)
per_page = param_to_integer(params["per_page"], 36)
date = Date.utc_today()
year = param_to_integer(params["year"], date.year)
month = param_to_integer(params["month"], date.month)
options = %{
sort_by: sort_by,
sort_order: sort_order,
page: page,
per_page: per_page,
year: year,
month: month
}
budgets = Keihi.list_budgets(current_user, options)
# both options and budgets change per click of my <.link> tag
# IO.inspect(options, label: "options")
# IO.inspect(budgets, label: "budgets")
socket =
socket
|> stream(:budgets, budgets)
|> assign(:selected_budget, select_budget(budgets, param_to_integer(params["id"], 0)))
|> assign(:options, options)
{:noreply, socket}
end
I also tried to set the stream to reset likeso:
|> stream(:budgets, budgets, reset: true)
with no changes.
Any clues? Of course I can just stay on 0.19.5, but I’m wondering if I’m doing something wrong here.