Skip to content

Commit

Permalink
fix: use extended types in street mode buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
vesameskanen committed Oct 9, 2023
1 parent fc8989c commit c224351
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/component/StreetModeSelectorButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ import { intlShape } from 'react-intl';
import Icon from './Icon';
import { displayDistance } from '../util/geo-utils';
import { durationToString } from '../util/timeUtils';
import { getRouteMode } from '../util/modeUtils';
import {
getTotalDistance,
getTotalBikingDistance,
compressLegs,
} from '../util/legUtils';

const getMode = (leg, config) => {
return config.useExtendedRouteTypes
? getRouteMode(leg.route) || leg.mode.toLowerCase()
: leg.mode.toLowerCase();
};

export const StreetModeSelectorButton = (
{ icon, name, plan, onClick },
{ config, intl },
Expand Down Expand Up @@ -61,7 +68,7 @@ export const StreetModeSelectorButton = (
obj => obj.mode !== 'WALK' && obj.mode !== 'BICYCLE',
);
if (publicModes.length > 0) {
const firstMode = publicModes[0].mode.toLowerCase();
const firstMode = getMode(publicModes[0], config);
secondaryIcon = `icon-icon_${firstMode}`;
if (firstMode === 'subway') {
metroColor = '#CA4000';
Expand All @@ -75,7 +82,7 @@ export const StreetModeSelectorButton = (
obj.mode !== 'WALK' && obj.mode !== 'BICYCLE' && obj.mode !== 'CAR',
);
if (publicModes.length > 0) {
mode = publicModes[0].mode.toLowerCase();
mode = getMode(publicModes[0], config);
break;
}
}
Expand Down

0 comments on commit c224351

Please sign in to comment.