Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Antiik91 committed Dec 16, 2024
2 parents cad43d9 + b57ccb2 commit 01c084a
Show file tree
Hide file tree
Showing 25 changed files with 698 additions and 234 deletions.
30 changes: 28 additions & 2 deletions app/component/itinerary/Itinerary.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import RouteNumberContainer from '../RouteNumberContainer';
import { getActiveLegAlertSeverityLevel } from '../../util/alertUtils';
import {
getLegMode,
splitLegsAtViaPoints,
compressLegs,
getLegBadgeProps,
isCallAgencyLeg,
Expand Down Expand Up @@ -287,7 +288,8 @@ const Itinerary = (
const mobile = bp => !(bp === 'large');
const legs = [];
let noTransitLegs = true;
const compressedLegs = compressLegs(itinerary.legs).map(leg => ({
const splitLegs = splitLegsAtViaPoints(itinerary.legs, intermediatePlaces);
const compressedLegs = compressLegs(splitLegs).map(leg => ({
...leg,
}));
let intermediateSlack = 0;
Expand Down Expand Up @@ -389,9 +391,14 @@ const Itinerary = (
renderBar = false;
addition += legLength; // carry over the length of the leg to the next
}
// There are two places which inject ViaLegs in this logic, but we certainly
// don't want to add it twice in the same place with the same key, so we
// record whether we added it here at the first place.
let viaAdded = false;
if (leg.intermediatePlace) {
onlyIconLegs += 1;
legs.push(<ViaLeg key={`via_${leg.mode}_${startMs}`} />);
viaAdded = true;
}
if (isLegOnFoot(leg) && renderBar) {
const walkingTime = Math.floor(leg.duration / 60);
Expand Down Expand Up @@ -555,7 +562,8 @@ const Itinerary = (
if (
previousLeg &&
!previousLeg.intermediatePlace &&
connectsFromViaPoint(leg, intermediatePlaces)
connectsFromViaPoint(leg, intermediatePlaces) &&
!viaAdded
) {
legs.push(<ViaLeg key={`via_${leg.mode}_${startMs}`} />);
}
Expand Down Expand Up @@ -970,13 +978,15 @@ Itinerary.propTypes = {
intermediatePlaces: PropTypes.arrayOf(locationShape),
hideSelectionIndicator: PropTypes.bool,
lowestCo2value: PropTypes.number,
viaPoints: PropTypes.arrayOf(locationShape),
};

Itinerary.defaultProps = {
passive: false,
intermediatePlaces: [],
hideSelectionIndicator: true,
lowestCo2value: 0,
viaPoints: [],
};

Itinerary.contextTypes = {
Expand Down Expand Up @@ -1021,6 +1031,16 @@ const containerComponent = createFragmentContainer(ItineraryWithBreakpoint, {
intermediatePlaces {
stop {
zoneId
gtfsId
parentStation {
gtfsId
}
}
arrival {
scheduledTime
estimated {
time
}
}
}
route {
Expand Down Expand Up @@ -1056,6 +1076,9 @@ const containerComponent = createFragmentContainer(ItineraryWithBreakpoint, {
name
stop {
gtfsId
parentStation {
gtfsId
}
zoneId
alerts {
alertSeverityLevel
Expand All @@ -1075,6 +1098,9 @@ const containerComponent = createFragmentContainer(ItineraryWithBreakpoint, {
to {
stop {
gtfsId
parentStation {
gtfsId
}
zoneId
alerts {
alertSeverityLevel
Expand Down
9 changes: 9 additions & 0 deletions app/component/itinerary/ItineraryDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@ const withRelay = createFragmentContainer(
}
}
}
parentStation {
gtfsId
}
}
}
to {
Expand Down Expand Up @@ -553,6 +556,9 @@ const withRelay = createFragmentContainer(
}
}
}
parentStation {
gtfsId
}
}
vehicleParking {
vehicleParkingId
Expand All @@ -574,6 +580,9 @@ const withRelay = createFragmentContainer(
code
platformCode
zoneId
parentStation {
gtfsId
}
}
}
realTime
Expand Down
1 change: 1 addition & 0 deletions app/component/itinerary/ItineraryPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ export default function ItineraryPage(props, context) {
params.to,
query.time,
query.arriveBy,
query.intermediatePlaces,
]);

useEffect(() => {
Expand Down
13 changes: 7 additions & 6 deletions app/component/itinerary/MobileTicketPurchaseInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import PropTypes from 'prop-types';
import React from 'react';
import { intlShape, FormattedMessage } from 'react-intl';
import { configShape, fareShape } from '../../util/shapes';

import { renderZoneTicket } from './ZoneTicket';
import { getAlternativeFares } from '../../util/fareUtils';
import ExternalLink from '../ExternalLink';
import { addAnalyticsEvent } from '../../util/analyticsUtils';

export default function MobileTicketPurchaseInformation(
Expand Down Expand Up @@ -60,15 +58,18 @@ export default function MobileTicketPurchaseInformation(
return (
<div className="itinerary-ticket-information-purchase">
{faresInfo()}
<div className="app-link plausible-event-name=Ticket+Purchase+Link">
<ExternalLink
href={config.ticketPurchaseLink(fare, config.ticketLinkOperatorCode)}
<div className="app-link">
<a
className={config.analyticsClass}
onClick={() =>
addAnalyticsEvent({ event: 'journey_planner_open_app' })
}
href={config.ticketPurchaseLink(fare, config.ticketLinkOperatorCode)}
target="_blank"
rel="noopener noreferrer"
>
<FormattedMessage id={config.ticketButtonTextId} />
</ExternalLink>
</a>
</div>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions app/component/itinerary/OriginDestinationBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class OriginDestinationBar extends React.Component {
let action;
if (id === parseInt(id, 10)) {
// id = via point index
// item == { ...gtfsId: 'HSL:1000004' }
action = 'EditJourneyViaPoint';
const points = [...this.props.viaPoints];
points[id] = { ...item };
Expand Down
3 changes: 3 additions & 0 deletions app/component/itinerary/PlanConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const planConnection = graphql`
$first: Int
$before: String
$last: Int
$via: [PlanViaLocationInput!]
) {
plan: planConnection(
dateTime: $datetime
Expand All @@ -28,6 +29,7 @@ const planConnection = graphql`
origin: $fromPlace
destination: $toPlace
modes: $modes
via: $via
preferences: {
accessibility: { wheelchair: { enabled: $wheelchair } }
street: {
Expand Down Expand Up @@ -131,6 +133,7 @@ const planConnection = graphql`
gtfsId
}
scheduledDeparture
serviceDay
}
stoptimes {
stop {
Expand Down
23 changes: 11 additions & 12 deletions app/component/itinerary/mobile-ticket-purchase-information.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,26 @@
}

.app-link {
.external-link-container {
border: 0;
line-height: 25px;
padding: 0 10px;

a.external-link {
font-size: 16px;
color: $primary-color;
}
}

line-height: 30px;
padding: 0 10px;
font-size: 16px;
color: $primary-color;
border: 0;
position: absolute;
right: 24px;
display: flex;
justify-content: space-evenly;
display: flex;
align-items: center;
min-width: 140px;
height: 40px;
background: #fff;
font-weight: $font-weight-medium;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
border-radius: 20px;

a {
display: inline-block;
text-decoration: none;
}
}
}
56 changes: 31 additions & 25 deletions app/component/itinerary/navigator/NaviCardContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import {
getItineraryAlerts,
getTransitLegState,
LEGTYPE,
DESTINATION_RADIUS,
} from './NaviUtils';
import { updateClient, getTopics } from '../ItineraryPageUtils';

const DESTINATION_RADIUS = 20; // meters
const TIME_AT_DESTINATION = 3; // * 10 seconds
const TOPBAR_PADDING = 8; // pixels

Expand Down Expand Up @@ -54,6 +54,8 @@ function NaviCardContainer(
const cardRef = useRef(null);
const { intl, config, match, router } = context;
const handleRemove = index => {
const msg = messages.get(activeMessages[index].id);
msg.closed = true; // remember closing action
setActiveMessages(activeMessages.filter((_, i) => i !== index));
};

Expand Down Expand Up @@ -92,43 +94,46 @@ function NaviCardContainer(
// Alerts for NaviStack
addMessages(
incomingMessages,
getItineraryAlerts(legs, intl, messages, match.params, router),
getItineraryAlerts(
legs,
time,
position,
origin,
intl,
messages,
match.params,
router,
),
);

if (currentLeg) {
if (nextLeg?.transitLeg) {
// Messages for NaviStack.
addMessages(incomingMessages, [
...getTransitLegState(nextLeg, intl, messages, time),
...getAdditionalMessages(nextLeg, time, intl, config, messages),
]);
}

if (legChanged) {
updateClient(topics, context);
if (nextLeg?.transitLeg) {
// Messages for NaviStack.
addMessages(incomingMessages, [
...getTransitLegState(nextLeg, intl, messages, time),
...getAdditionalMessages(nextLeg, time, intl, config, messages),
]);
}
if (legChanged) {
updateClient(topics, context);
setCardExpanded(false);
if (currentLeg) {
focusToLeg?.(currentLeg);
setCardExpanded(false);
}
}
if (incomingMessages.size || legChanged) {
// Handle messages when new messages arrives.

// Current active messages. Filter away expired messages.
const previousValidMessages = legChanged
? activeMessages.filter(m => m.expiresOn < time)
? activeMessages.filter(m => !m.expiresOn || m.expiresOn > time)
: activeMessages;

// handle messages that are updated.
const updatedMessages = previousValidMessages.map(msg => {
const incoming = incomingMessages.get(msg.id);
if (incoming) {
incomingMessages.delete(msg.id);
return incoming;
}
return msg;
});
const keptMessages = previousValidMessages.filter(
msg => !incomingMessages.get(msg.id),
);
const newMessages = Array.from(incomingMessages.values());
setActiveMessages([...updatedMessages, ...newMessages]);
setActiveMessages([...keptMessages, ...newMessages]);
setMessages(new Map([...messages, ...incomingMessages]));
}

Expand Down Expand Up @@ -222,7 +227,8 @@ NaviCardContainer.propTypes = {
lat: PropTypes.number,
lon: PropTypes.number,
}),
mapLayerRef: PropTypes.func.isRequired,
mapLayerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
.isRequired,
origin: PropTypes.shape({
x: PropTypes.number.isRequired,
y: PropTypes.number.isRequired,
Expand Down
12 changes: 8 additions & 4 deletions app/component/itinerary/navigator/NaviContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import NaviBottom from './NaviBottom';
import NaviCardContainer from './NaviCardContainer';
import { useRealtimeLegs } from './hooks/useRealtimeLegs';
import NavigatorOutroModal from './navigatoroutro/NavigatorOutroModal';
import { DESTINATION_RADIUS } from './NaviUtils';

const DESTINATION_RADIUS = 20; // meters
const ADDITIONAL_ARRIVAL_TIME = 60000; // 60 seconds in ms

function NaviContainer(
Expand All @@ -27,7 +27,10 @@ function NaviContainer(
) {
const [isPositioningAllowed, setPositioningAllowed] = useState(false);

const position = getStore('PositionStore').getLocationState();
let position = getStore('PositionStore').getLocationState();
if (!position.hasLocation) {
position = null;
}

const {
realTimeLegs,
Expand All @@ -41,7 +44,7 @@ function NaviContainer(
} = useRealtimeLegs(relayEnvironment, legs);

useEffect(() => {
if (position.hasLocation) {
if (position) {
mapRef?.enableMapTracking();
setPositioningAllowed(true);
} else {
Expand Down Expand Up @@ -107,7 +110,8 @@ NaviContainer.propTypes = {
isNavigatorIntroDismissed: PropTypes.bool,
// eslint-disable-next-line
mapRef: PropTypes.object,
mapLayerRef: PropTypes.func.isRequired,
mapLayerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
.isRequired,
};

NaviContainer.contextTypes = {
Expand Down
Loading

0 comments on commit 01c084a

Please sign in to comment.