Skip to content

Commit

Permalink
Only keep one list of closures.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaddox5 committed Dec 9, 2024
1 parent eb470fd commit a548e78
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
12 changes: 7 additions & 5 deletions assets/src/components/v2/elevator/elevator_closures_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,23 @@ const OutsideClosureList = ({

interface Props extends WrappedComponentProps {
id: string;
in_station_closures: Closure[];
other_stations_with_closures: StationWithClosures[];
stations_with_closures: StationWithClosures[];
station_id: string;
}

const ElevatorClosuresList = ({
other_stations_with_closures: stations,
in_station_closures: inStationClosures,
stations_with_closures: stations,
station_id: stationId,
lastUpdate,
onFinish,
}: Props) => {
return (
<div className="elevator-closures-list">
<InStationSummary closures={inStationClosures} />
<InStationSummary
closures={stations
.filter((s) => s.id === stationId)
.flatMap((s) => s.closures)}
/>
<OutsideClosureList
stations={stations}
stationId={stationId}
Expand Down
7 changes: 3 additions & 4 deletions lib/screens/v2/candidate_generator/elevator/closures.ex
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ defmodule Screens.V2.CandidateGenerator.Elevator.Closures do
{elevator_widget_instance, header_footer_variant} =
if is_nil(current_elevator_closure) do
{%ElevatorClosuresList{
in_station_closures: in_station_closures,
other_stations_with_closures:
format_outside_closures(
stations_with_closures:
build_stations_with_closures(
elevator_alerts,
parent_station_map,
routes_map
Expand Down Expand Up @@ -160,7 +159,7 @@ defmodule Screens.V2.CandidateGenerator.Elevator.Closures do
}
end

defp format_outside_closures(alerts, station_id_to_name, station_id_to_routes) do
defp build_stations_with_closures(alerts, station_id_to_name, station_id_to_routes) do
alerts
|> Enum.group_by(&get_parent_station_id_from_informed_entities(&1.informed_entities))
|> Enum.map(fn {parent_station_id, alerts} ->
Expand Down
11 changes: 4 additions & 7 deletions lib/screens/v2/widget_instance/elevator_closures_list.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ defmodule Screens.V2.WidgetInstance.ElevatorClosuresList do
alias Screens.V2.WidgetInstance.Elevator.Closure
alias ScreensConfig.V2.Elevator

defstruct ~w[app_params in_station_closures other_stations_with_closures station_id]a
defstruct ~w[app_params stations_with_closures station_id]a

@type t :: %__MODULE__{
app_params: Elevator.t(),
in_station_closures: list(Closure.t()),
other_stations_with_closures: list(__MODULE__.Station.t()),
stations_with_closures: list(__MODULE__.Station.t()),
station_id: String.t()
}

Expand All @@ -34,14 +33,12 @@ defmodule Screens.V2.WidgetInstance.ElevatorClosuresList do

def serialize(%__MODULE__{
app_params: %Elevator{elevator_id: id},
in_station_closures: in_station_closures,
other_stations_with_closures: other_stations_with_closures,
stations_with_closures: stations_with_closures,
station_id: station_id
}),
do: %{
id: id,
in_station_closures: in_station_closures,
other_stations_with_closures: other_stations_with_closures,
stations_with_closures: stations_with_closures,
station_id: station_id
}

Expand Down

0 comments on commit a548e78

Please sign in to comment.