Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use graphQL alias to query leg id #5153

Merged
merged 4 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/component/itinerary/NaviCardContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ function NaviCardContainer(
incomingMessages.set(alert.id, alert);
});

const legChanged = newLeg?.id
? newLeg.id !== currentLeg?.id
const legChanged = newLeg?.legId
? newLeg.legId !== currentLeg?.legId
: currentLeg?.mode !== newLeg?.mode;
const l = currentLeg || newLeg;

Expand Down
2 changes: 1 addition & 1 deletion app/component/itinerary/NaviContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function NaviContainer(

if (lastTransitLeg) {
const rtLeg = realTimeLegs.find(leg => {
return leg.id === lastTransitLeg.id;
return leg.legId === lastTransitLeg.legId;
});
arrivalChange = legTime(rtLeg.end) - legTime(lastTransitLeg.end);
}
Expand Down
8 changes: 4 additions & 4 deletions app/component/itinerary/NaviUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ export const getAdditionalMessages = (leg, time, intl, config, messages) => {
};

export const getTransitLegState = (leg, intl, messages) => {
const { start, realtimeState, from, mode, id } = leg;
const { start, realtimeState, from, mode, legId } = leg;
const { scheduledTime, estimated } = start;
if (mode === 'WALK') {
return null;
}
const previousMessage = messages.get(id);
const previousMessage = messages.get(legId);
const prevSeverity = previousMessage ? previousMessage.severity : null;

const late = estimated?.delay > 0;
Expand Down Expand Up @@ -117,7 +117,7 @@ export const getTransitLegState = (leg, intl, messages) => {
severity = 'INFO';
}
const state = severity
? { severity, content, id, expiresOn: 'legChange' }
? { severity, content, id: legId, expiresOn: 'legChange' }
: null;
return state;
};
Expand All @@ -142,7 +142,7 @@ export const getItineraryAlerts = (realTimeLegs, intl, messages) => {
});
}
if (transferProblem !== null) {
const transferId = `transfer-${transferProblem[0].id}-${transferProblem[1].id}}`;
const transferId = `transfer-${transferProblem[0].legId}-${transferProblem[1].legId}}`;
if (!messages.get(transferId)) {
// todo no current design
content = (
Expand Down
2 changes: 1 addition & 1 deletion app/component/itinerary/PlanConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const planConnection = graphql`
mode
distance
transitLeg
id
legId: id
interlineWithPreviousLeg
duration
headsign
Expand Down
6 changes: 3 additions & 3 deletions app/component/itinerary/hooks/useRealtimeLegs.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ const useRealtimeLegs = (initialLegs, mapRef, relayEnvironment) => {
fetchQuery(
relayEnvironment,
legQuery,
{ id: leg.id },
{ id: leg.legId },
{ force: true },
).toPromise(),
);
const responses = await Promise.all(legQueries);
return responses.reduce(
(map, response) => ({ ...map, [response.leg.id]: response.leg }),
(map, response) => ({ ...map, [response.leg.legId]: response.leg }),
{},
);
},
Expand All @@ -49,7 +49,7 @@ const useRealtimeLegs = (initialLegs, mapRef, relayEnvironment) => {
);

const rtLegs = initialLegs.map(l => {
const rtLeg = l.id ? rtLegMap[l.id] : null;
const rtLeg = l.legId ? rtLegMap[l.legId] : null;
if (rtLeg) {
return {
...l,
Expand Down
2 changes: 1 addition & 1 deletion app/component/itinerary/queries/LegQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { graphql } from 'react-relay';
const legQuery = graphql`
query LegQuery($id: String!) {
leg(id: $id) {
id
legId: id
start {
scheduledTime
estimated {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"license": "(AGPL-3.0 OR EUPL-1.2)",
"dependencies": {
"@digitransit-search-util/digitransit-search-util-serialize": "0.0.2",
"axios": "1.6.7"
"axios": "1.7.7"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"@hsl-fi/site-header": "4.5.0",
"@mapbox/sphericalmercator": "1.1.0",
"@mapbox/vector-tile": "1.3.1",
"axios": "1.6.7",
"axios": "1.7.7",
"babel-plugin-dynamic-import-node": "2.3.3",
"babel-plugin-relay": "16.2.0",
"body-parser": "1.20.3",
Expand Down
27 changes: 24 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2236,7 +2236,7 @@ __metadata:
resolution: "@digitransit-search-util/digitransit-search-util-get-json@workspace:digitransit-search-util/packages/digitransit-search-util-get-json"
dependencies:
"@digitransit-search-util/digitransit-search-util-serialize": 0.0.2
axios: 1.6.7
axios: 1.7.7
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -7573,7 +7573,18 @@ __metadata:
languageName: node
linkType: hard

"axios@npm:1.6.7, axios@npm:^1.6.1":
"axios@npm:1.7.7":
version: 1.7.7
resolution: "axios@npm:1.7.7"
dependencies:
follow-redirects: ^1.15.6
form-data: ^4.0.0
proxy-from-env: ^1.1.0
checksum: 882d4fe0ec694a07c7f5c1f68205eb6dc5a62aecdb632cc7a4a3d0985188ce3030e0b277e1a8260ac3f194d314ae342117660a151fabffdc5081ca0b5a8b47fe
languageName: node
linkType: hard

"axios@npm:^1.6.1":
version: 1.6.7
resolution: "axios@npm:1.6.7"
dependencies:
Expand Down Expand Up @@ -11197,7 +11208,7 @@ __metadata:
async: ^3.2.2
autoprefixer: 9.8.6
axe-core: ^4.7.2
axios: 1.6.7
axios: 1.7.7
babel-loader: 8.2.5
babel-plugin-dynamic-import-node: 2.3.3
babel-plugin-inline-react-svg: 2.0.2
Expand Down Expand Up @@ -13623,6 +13634,16 @@ __metadata:
languageName: node
linkType: hard

"follow-redirects@npm:^1.15.6":
version: 1.15.9
resolution: "follow-redirects@npm:1.15.9"
peerDependenciesMeta:
debug:
optional: true
checksum: 859e2bacc7a54506f2bf9aacb10d165df78c8c1b0ceb8023f966621b233717dab56e8d08baadc3ad3b9db58af290413d585c999694b7c146aaf2616340c3d2a6
languageName: node
linkType: hard

"for-each@npm:^0.3.3":
version: 0.3.3
resolution: "for-each@npm:0.3.3"
Expand Down
Loading