From 3e9807b393d8e1acc6b6f839aacc720c8908322b Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 25 Jan 2020 15:46:42 +0100 Subject: map, journey view: handle renamed stations --- lib/Travelynx/Controller/Traveling.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/Travelynx/Controller') diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index 421032f..8d1a901 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -470,10 +470,24 @@ sub map_history { for my $journey (@journeys) { - my @route = map { $_->[0] } @{ $journey->{route} }; + my @route = map { $_->[0] } @{ $journey->{route} }; + my $from_index = first_index { $_ eq $journey->{from_name} } @route; my $to_index = first_index { $_ eq $journey->{to_name} } @route; + if ( $from_index == -1 ) { + my $rename = $self->app->renamed_station; + $from_index + = first_index { ( $rename->{$_} // $_ ) eq $journey->{from_name} } + @route; + } + if ( $to_index == -1 ) { + my $rename = $self->app->renamed_station; + $to_index + = first_index { ( $rename->{$_} // $_ ) eq $journey->{to_name} } + @route; + } + if ( $from_index == -1 or $to_index == -1 ) { -- cgit v1.2.3