From 9178751bac3866a95d99385250c775f71d76ed42 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sat, 25 Apr 2026 17:22:51 -0500 Subject: [PATCH] fix(rover): push stations_updated to map hook on add/edit/toggle/delete --- lib/microwaveprop_web/live/rover_live.ex | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/microwaveprop_web/live/rover_live.ex b/lib/microwaveprop_web/live/rover_live.ex index ad758dc8..a6095041 100644 --- a/lib/microwaveprop_web/live/rover_live.ex +++ b/lib/microwaveprop_web/live/rover_live.ex @@ -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