summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Controller
diff options
context:
space:
mode:
authorDerf Null <derf@finalrewind.org>2023-06-08 10:20:13 +0200
committerDerf Null <derf@finalrewind.org>2023-06-08 10:20:13 +0200
commit619646b533bc27575131f7a521aac30a1431bfb1 (patch)
tree2594110d1b21265fc16e0931e5e97427cfc5706d /lib/Travelynx/Controller
parente275fc6dbe84afa1c6dcff51ea34f35415a4f771 (diff)
warn when trying to check out at invalid unscheduled station1.32.3
Closes #72
Diffstat (limited to 'lib/Travelynx/Controller')
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm33
1 files changed, 28 insertions, 5 deletions
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index 2463bb5..d309753 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -845,20 +845,37 @@ sub station {
} @results;
}
+ my $user_status = $self->get_user_status;
+
+ my $can_check_out = 0;
+ if ( $user_status->{checked_in} ) {
+ for my $stop ( @{ $user_status->{route_after} } ) {
+ if (
+ $stop->[1] eq $status->{station_eva}
+ or List::Util::any { $stop->[1] eq $_->{uic} }
+ @{ $status->{related_stations} }
+ )
+ {
+ $can_check_out = 1;
+ last;
+ }
+ }
+ }
+
my $connections_p;
if ($train) {
@results
= grep { $_->type . ' ' . $_->train_no eq $train } @results;
}
else {
- my $user = $self->get_user_status;
- if ( $user->{cancellation}
+ if ( $user_status->{cancellation}
and $status->{station_eva} eq
- $user->{cancellation}{dep_eva} )
+ $user_status->{cancellation}{dep_eva} )
{
$connections_p = $self->get_connecting_trains_p(
- eva => $user->{cancellation}{dep_eva},
- destination_name => $user->{cancellation}{arr_name}
+ eva => $user_status->{cancellation}{dep_eva},
+ destination_name =>
+ $user_status->{cancellation}{arr_name}
);
}
else {
@@ -878,6 +895,8 @@ sub station {
hafas => $use_hafas,
station => $status->{station_name},
related_stations => $status->{related_stations},
+ user_status => $user_status,
+ can_check_out => $can_check_out,
connections => $connecting_trains,
title => "travelynx: $status->{station_name}",
version => $self->app->config->{version}
@@ -893,6 +912,8 @@ sub station {
hafas => $use_hafas,
station => $status->{station_name},
related_stations => $status->{related_stations},
+ user_status => $user_status,
+ can_check_out => $can_check_out,
title => "travelynx: $status->{station_name}",
version => $self->app->config->{version}
// 'UNKNOWN',
@@ -908,6 +929,8 @@ sub station {
hafas => $use_hafas,
station => $status->{station_name},
related_stations => $status->{related_stations},
+ user_status => $user_status,
+ can_check_out => $can_check_out,
title => "travelynx: $status->{station_name}",
version => $self->app->config->{version} // 'UNKNOWN',
);