Skip to content

Commit

Permalink
Prevent delays from serializing diagrams. (#2103)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaddox5 authored Jul 1, 2024
1 parent 6f25359 commit 641e29d
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions lib/screens/v2/widget_instance/reconstructed_alert.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1206,18 +1206,7 @@ defmodule Screens.V2.WidgetInstance.ReconstructedAlert do
def serialize(widget, log_fn \\ &Logger.warning/1)

def serialize(%__MODULE__{is_full_screen: true, alert: %Alert{effect: effect}} = t, log_fn) do
diagram_data =
case DisruptionDiagram.serialize(t) do
{:ok, serialized_diagram} ->
%{disruption_diagram: serialized_diagram}

{:error, reason} ->
log_fn.(
"[disruption diagram error] alert_id=#{t.alert.id} home_stop=#{t.location_context.home_stop} #{reason}"
)

%{}
end
diagram_data = serialize_diagram(t, log_fn)

main_data = pick_layout_serializer(t, diagram_data, effect, dual_screen_alert?(t))

Expand All @@ -1237,6 +1226,22 @@ defmodule Screens.V2.WidgetInstance.ReconstructedAlert do
end
end

defp serialize_diagram(%__MODULE__{alert: %Alert{effect: :delay}}, _), do: %{}

defp serialize_diagram(%__MODULE__{} = t, log_fn) do
case DisruptionDiagram.serialize(t) do
{:ok, serialized_diagram} ->
%{disruption_diagram: serialized_diagram}

{:error, reason} ->
log_fn.(
"[disruption diagram error] alert_id=#{t.alert.id} home_stop=#{t.location_context.home_stop} #{reason}"
)

%{}
end
end

def pick_layout_serializer(t, diagram, effect, true) when diagram == %{} and effect != :delay,
do: serialize_dual_screen_fallback_alert(t)

Expand Down

0 comments on commit 641e29d

Please sign in to comment.