From b0b685c081112df9d867f44f574ab6dfba27a7ee Mon Sep 17 00:00:00 2001 From: Christian Maddox Date: Thu, 12 Sep 2024 10:17:02 -0400 Subject: [PATCH] feat: Sectional Audio (#2190) * Add Sectional as screen that can play audio. * Remove Busway exception in Inspector. * Version bump for screens_config. * Add now to widget instance struct. * Only return 2 times if both are < 2 minutes away. * Change track # readout for bus. * Fix logic for readouts. * Always read out train headsigns. * Address PR feedback. * Moved now into options list. * Fix comment. * Removed unnecessary parameter and made function private. * Add ID to serialized route pill. * Improved test. * Made now it's own required parameter. --- assets/src/components/admin/inspector.tsx | 36 +-- .../v2/candidate_generator/bus_eink.ex | 4 +- .../v2/candidate_generator/bus_shelter.ex | 4 +- lib/screens/v2/candidate_generator/busway.ex | 8 +- .../v2/candidate_generator/dup/departures.ex | 3 +- lib/screens/v2/candidate_generator/gl_eink.ex | 4 +- .../v2/candidate_generator/solari_large.ex | 4 +- .../candidate_generator/widgets/departures.ex | 14 +- lib/screens/v2/screen_audio_data.ex | 4 +- lib/screens/v2/widget_instance/departures.ex | 89 +++--- .../widget_instance/serializer/route_pill.ex | 2 + .../views/v2/audio/departures_view.ex | 16 +- mix.exs | 2 +- mix.lock | 21 +- .../v2/candidate_generator/bus_eink_test.exs | 2 +- .../candidate_generator/bus_shelter_test.exs | 4 +- .../v2/candidate_generator/busway_test.exs | 4 +- .../dup/departures_test.exs | 132 ++++++--- .../candidate_generator/solari_large_test.exs | 2 +- .../widgets/departures_test.exs | 3 +- .../v2/widget_instance/departures_test.exs | 259 +++++++++++++++--- .../views/v2/audio/departures_view_test.exs | 129 +++++++++ 22 files changed, 564 insertions(+), 182 deletions(-) diff --git a/assets/src/components/admin/inspector.tsx b/assets/src/components/admin/inspector.tsx index 80f23d9f1..40ff03d91 100644 --- a/assets/src/components/admin/inspector.tsx +++ b/assets/src/components/admin/inspector.tsx @@ -86,7 +86,7 @@ const Inspector: ComponentType = () => { - + )} @@ -305,10 +305,7 @@ const DataControls: ComponentType<{ ); }; -const AudioControls: ComponentType<{ - config: Config; - screen: ScreenWithId; -}> = ({ config, screen }) => { +const AudioControls: ComponentType<{ screen: ScreenWithId }> = ({ screen }) => { const [isPlaying, setIsPlaying] = useState(false); const [ssml, setSSML] = useState(null); const dialogRef = useRef(null); @@ -318,24 +315,9 @@ const AudioControls: ComponentType<{ [dialogRef, ssml], ); - let audioPath: string | null = null; - let v1ScreenId: string | null = null; - - if (AUDIO_SCREEN_TYPES.has(screen.config.app_id)) { - // Temporarily special-case Busway screens while V2 doesn't support audio - // yet, in a way that aligns with how they're configured in reality (using - // the audio endpoint of a corresponding V1 screen). - if (screen.config.app_id == "busway_v2") { - const maybeV1Id = screen.id.replace(/-V2$/, ""); - - if (maybeV1Id != screen.id && config.screens[maybeV1Id]) { - audioPath = `/audio/${maybeV1Id}`; - v1ScreenId = maybeV1Id; - } - } else { - audioPath = `/v2/audio/${screen.id}`; - } - } + const audioPath = AUDIO_SCREEN_TYPES.has(screen.config.app_id) + ? `/v2/audio/${screen.id}` + : null; return (
@@ -361,14 +343,6 @@ const AudioControls: ComponentType<{ - {v1ScreenId && ( -
- - (from v1 screen {v1ScreenId}) - -
- )} -