Skip to content

Commit

Permalink
fix: GL E-Ink DeparturesNoData (#1861)
Browse files Browse the repository at this point in the history
* Corrected slot name in props.

* Gave v1 gl_eink the ability to handle when light_rail is disabled.

* Changed slot name.
  • Loading branch information
cmaddox5 authored Oct 11, 2023
1 parent 78dee5e commit e5b9ffb
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
11 changes: 11 additions & 0 deletions lib/screens/gl_screen_data.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ defmodule Screens.GLScreenData do
alias Screens.Config.{Gl, State}

def by_screen_id(screen_id, is_screen) do
if State.mode_disabled?(:light_rail) do
%{
force_reload: false,
success: false
}
else
by_enabled_screen_id(screen_id, is_screen)
end
end

defp by_enabled_screen_id(screen_id, is_screen) do
%Gl{
stop_id: stop_id,
route_id: route_id,
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/nearby_departures.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Screens.NearbyDepartures do
alias Screens.Config.{Gl, State}

def by_screen_id(screen_id) do
if State.mode_disabled?(:bus) do
if State.mode_disabled?(:bus) or State.mode_disabled?(:light_rail) do
[]
else
by_enabled_screen_id(screen_id)
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/v2/candidate_generator/gl_eink.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ defmodule Screens.V2.CandidateGenerator.GlEink do
# slot to its left, while still allowing the normal flex zone
# to appear on the bottom screen.
top_takeover: [
:full_main_content,
:full_body_top_screen,
Builder.with_paging({:flex_zone, %{one_medium: [:medium]}}, 2),
:footer
],
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/v2/widget_instance/departures_no_data.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule Screens.V2.WidgetInstance.DeparturesNoData do
def slot_names(%__MODULE__{slot_name: slot_name}) when not is_nil(slot_name),
do: [slot_name]

def slot_names(%__MODULE__{screen: %Screen{app_id: :gl_eink_v2}}), do: [:full_main_content]
def slot_names(%__MODULE__{screen: %Screen{app_id: :gl_eink_v2}}), do: [:full_body_top_screen]
def slot_names(_instance), do: [:main_content]
def widget_type(_instance), do: :departures_no_data
def valid_candidate?(_instance), do: true
Expand Down
2 changes: 1 addition & 1 deletion test/screens/v2/candidate_generator/gl_eink_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ defmodule Screens.V2.CandidateGenerator.GlEinkTest do
:footer
],
top_takeover: [
:full_main_content,
:full_body_top_screen,
{{0, :flex_zone}, %{one_medium: [{0, :medium}]}},
{{1, :flex_zone}, %{one_medium: [{1, :medium}]}},
:footer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule Screens.V2.WidgetInstance.DeparturesNoDataTest do

describe "slot_names/1" do
test "returns full_body_top_screen for gl_eink_v2", %{gl_eink_widget: gl_eink_widget} do
assert [:full_main_content] == WidgetInstance.slot_names(gl_eink_widget)
assert [:full_body_top_screen] == WidgetInstance.slot_names(gl_eink_widget)
end

test "returns main_content", %{widget: widget} do
Expand Down

0 comments on commit e5b9ffb

Please sign in to comment.