From dcdea4247b6457202ce746814ff44d249c32d8b5 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 11 Jan 2021 22:09:00 +0100 Subject: train details: show cycle (if available) --- lib/DBInfoscreen/Controller/Stationboard.pm | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'lib/DBInfoscreen/Controller/Stationboard.pm') diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index 9bb09b1..2eb7b12 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -560,6 +560,9 @@ sub render_train { my $stationinfo_req = Mojo::Promise->new; my $route_req = Mojo::Promise->new; + my @requests + = ( $wagonorder_req, $utilization_req, $stationinfo_req, $route_req ); + if ( $departure->{wr_link} ) { $self->wagonorder->is_available_p( $result, $departure->{wr_link} ) ->then( @@ -769,9 +772,27 @@ sub render_train { } )->wait; + if ( $self->param('detailed') ) { + my $cycle_req = Mojo::Promise->new; + push( @requests, $cycle_req ); + $self->wagonorder->has_umlauf_p( $result->train_no )->then( + sub { + $departure->{has_cycle} = 1; + } + )->catch( + sub { + # nop + } + )->finally( + sub { + $cycle_req->resolve; + return; + } + )->wait; + } + # Defer rendering until all requests have completed - Mojo::Promise->all( $wagonorder_req, $utilization_req, $stationinfo_req, - $route_req )->then( + Mojo::Promise->all(@requests)->then( sub { $self->render( $template // '_train_details', -- cgit v1.2.3