Skip to content

Commit 71cefb5

Browse files
authored
Merge pull request #5223 from HSLdevcom/navifixes6
DT-6613, DT-6661 transfer cards, stable alerts and and misc fixes
2 parents f968968 + 67ae416 commit 71cefb5

File tree

8 files changed

+207
-134
lines changed

8 files changed

+207
-134
lines changed

app/component/itinerary/MobileTicketPurchaseInformation.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33
import { intlShape, FormattedMessage } from 'react-intl';
44
import { configShape, fareShape } from '../../util/shapes';
55
import { renderZoneTicket } from './ZoneTicket';
6-
import { getAlternativeFares } from '../../util/fareUtils';
6+
import { getAlternativeFares, formatFare } from '../../util/fareUtils';
77
import { addAnalyticsEvent } from '../../util/analyticsUtils';
88

99
export default function MobileTicketPurchaseInformation(
@@ -20,9 +20,7 @@ export default function MobileTicketPurchaseInformation(
2020
config.availableTickets,
2121
);
2222
const price =
23-
config.showTicketPrice && fare.price > 0
24-
? `${fare.price.toFixed(2)} €`.replace('.', ',')
25-
: '';
23+
config.showTicketPrice && fare.price > 0 ? formatFare(fare) : '';
2624

2725
const faresInfo = () => {
2826
const header = `${intl.formatMessage({

app/component/itinerary/TicketInformation.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { v4 as uuid } from 'uuid';
66
import { configShape, fareShape, legShape } from '../../util/shapes';
77
import { renderZoneTicket } from './ZoneTicket';
88
import Icon from '../Icon';
9-
import { getAlternativeFares } from '../../util/fareUtils';
9+
import { getAlternativeFares, formatFare } from '../../util/fareUtils';
1010

1111
export default function TicketInformation(
1212
{ fares, zones, legs },
@@ -66,9 +66,7 @@ export default function TicketInformation(
6666
: fare.ticketName}
6767
</div>
6868
{config.showTicketPrice && (
69-
<div className="ticket-description">
70-
{`${fare.price.toFixed(2)} €`}
71-
</div>
69+
<div className="ticket-description">{formatFare(fare)}</div>
7270
)}
7371
<Icon img="icon-icon_arrow-collapse--right" />
7472
</a>

app/component/itinerary/navigator/NaviCardContainer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ function NaviCardContainer(
132132
),
133133
);
134134

135-
if (match.location.query?.debug !== undefined && position) {
135+
if (
136+
match.location.query?.debug !== undefined &&
137+
position &&
138+
!messages.get('debug')?.closed
139+
) {
136140
const info1 = `lat: ${position.lat} lon: ${position.lon}`;
137141
const info2 = `status: ${position.status}`;
138142
const info3 = `locations: ${position.locationCount} watchId: ${position.watchId}`;

app/component/itinerary/navigator/NaviContainer.js

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import distance from '@digitransit-search-util/digitransit-search-util-distance';
22
import { routerShape } from 'found';
33
import PropTypes from 'prop-types';
4-
import React, { useEffect, useState } from 'react';
5-
import { checkPositioningPermission } from '../../../action/PositionActions';
4+
import React, { useEffect, useRef } from 'react';
65
import { legTime } from '../../../util/legUtils';
76
import { legShape, relayShape } from '../../../util/shapes';
87
import NaviBottom from './NaviBottom';
@@ -26,11 +25,13 @@ function NaviContainer(
2625
},
2726
{ getStore, router },
2827
) {
29-
const [isPositioningAllowed, setPositioningAllowed] = useState(false);
28+
const hasPosition = useRef(false);
3029

3130
let position = getStore('PositionStore').getLocationState();
3231
if (!position.hasLocation) {
3332
position = null;
33+
} else {
34+
hasPosition.current = true;
3435
}
3536

3637
const {
@@ -45,18 +46,8 @@ function NaviContainer(
4546
} = useRealtimeLegs(relayEnvironment, legs);
4647

4748
useEffect(() => {
48-
if (position) {
49-
mapRef?.enableMapTracking();
50-
setPositioningAllowed(true);
51-
} else {
52-
checkPositioningPermission().then(permission => {
53-
if (permission.state === 'granted') {
54-
mapRef?.enableMapTracking();
55-
setPositioningAllowed(true);
56-
}
57-
});
58-
}
59-
}, [mapRef]);
49+
mapRef?.enableMapTracking(); // try always, shows annoying notifier
50+
}, [mapRef, hasPosition.current]);
6051

6152
if (!realTimeLegs?.length) {
6253
return null;
@@ -80,9 +71,7 @@ function NaviContainer(
8071
<>
8172
<NaviCardContainer
8273
legs={realTimeLegs}
83-
focusToLeg={
84-
mapRef?.state.mapTracking || isPositioningAllowed ? null : focusToLeg
85-
}
74+
focusToLeg={position ? null : focusToLeg}
8675
time={time}
8776
position={position}
8877
mapLayerRef={mapLayerRef}

0 commit comments

Comments
 (0)