fix(rover): push stations_updated to map hook on add/edit/toggle/delete

This commit is contained in:
Graham McIntire 2026-04-25 17:22:51 -05:00
parent 915cd1f5a0
commit 9178751bac
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -209,7 +209,8 @@ defmodule MicrowavepropWeb.RoverLive do
{:ok, stations} ->
{:noreply,
socket
|> assign(fixed_stations: stations, station_form_error: nil)
|> assign_stations(stations)
|> assign(station_form_error: nil)
|> sync_url()}
{:error, msg} ->
@ -236,7 +237,8 @@ defmodule MicrowavepropWeb.RoverLive do
{:ok, stations} ->
{:noreply,
socket
|> assign(fixed_stations: stations, station_form_error: nil)
|> assign_stations(stations)
|> assign(station_form_error: nil)
|> sync_url()}
{:error, msg} ->
@ -344,13 +346,19 @@ defmodule MicrowavepropWeb.RoverLive do
defp handle_station_mutation(socket, id, fun) do
case fun.(socket, id) do
{:ok, stations} ->
{:noreply, socket |> assign(fixed_stations: stations) |> sync_url()}
{:noreply, socket |> assign_stations(stations) |> sync_url()}
{:error, _} ->
{:noreply, socket}
end
end
defp assign_stations(socket, stations) do
socket
|> assign(fixed_stations: stations)
|> push_event("stations_updated", %{stations: stations_for_compute(stations)})
end
defp sync_url(socket) do
push_patch(socket, to: rover_path(socket), replace: true)
end