From 2da48e05bef789e3d4f42588dbeb0ad4ca0a75d5 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 27 Jul 2022 13:54:20 +0200 Subject: move get_connecting_trains call from _checkeed_in to controller --- lib/Travelynx/Controller/Traveling.pm | 23 ++++++++++++++++++++++- templates/_checked_in.html.ep | 12 +++++------- templates/landingpage.html.ep | 1 - 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index 6a53fe0..0493d25 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -17,9 +17,20 @@ use Travel::Status::DE::IRIS::Stations; sub homepage { my ($self) = @_; if ( $self->is_user_authenticated ) { + my $status = $self->get_user_status; + my @connecting_trains; + if ( $status->{checked_in} ) { + if ( defined $status->{arrival_countdown} + and $status->{arrival_countdown} < ( 20 * 60 ) ) + { + @connecting_trains = $self->get_connecting_trains(); + } + } $self->render( 'landingpage', version => $self->app->config->{version} // 'UNKNOWN', + status => $status, + connections => \@connecting_trains, with_autocomplete => 1, with_geolocation => 1 ); @@ -348,7 +359,17 @@ sub status_card { delete $self->stash->{layout}; if ( $status->{checked_in} ) { - $self->render( '_checked_in', journey => $status ); + my @connecting_trains; + if ( defined $status->{arrival_countdown} + and $status->{arrival_countdown} < ( 20 * 60 ) ) + { + @connecting_trains = $self->get_connecting_trains(); + } + $self->render( + '_checked_in', + journey => $status, + connections => \@connecting_trains + ); } elsif ( $status->{cancellation} ) { my @connecting_trains = $self->get_connecting_trains( diff --git a/templates/_checked_in.html.ep b/templates/_checked_in.html.ep index bd1ddc6..f2b6eba 100644 --- a/templates/_checked_in.html.ep +++ b/templates/_checked_in.html.ep @@ -193,14 +193,12 @@

% } - % if (defined $journey->{arrival_countdown} and $journey->{arrival_countdown} < (20*60)) { - % if (my @connections = get_connecting_trains()) { - Verbindungen - % if ($journey->{arrival_countdown} < 0) { -

Zug auswählen zum Einchecken mit Zielwahl.

- % } - %= include '_connections', connections => \@connections, checkin_from => $journey->{arrival_countdown} < 0 ? $journey->{arr_ds100} : undef; + % if (my @connections = @{stash('connections') // []}) { + Verbindungen + % if ($journey->{arrival_countdown} < 0) { +

Zug auswählen zum Einchecken mit Zielwahl.

% } + %= include '_connections', connections => \@connections, checkin_from => $journey->{arrival_countdown} < 0 ? $journey->{arr_ds100} : undef; % } % if (defined $journey->{arrival_countdown} and $journey->{arrival_countdown} <= 0) {

diff --git a/templates/landingpage.html.ep b/templates/landingpage.html.ep index 61d136e..3e7d761 100644 --- a/templates/landingpage.html.ep +++ b/templates/landingpage.html.ep @@ -13,7 +13,6 @@ % }

- % my $status = get_user_status(); % if ($status->{checked_in}) { %= include '_checked_in', journey => $status; % } -- cgit v1.2.3