From 046a3c55c6adb4ef69cd5474ad2622431af9f35b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 13:39:36 +0000 Subject: [PATCH 01/18] chore(deps): bump decode-uri-component from 0.2.0 to 0.2.2 Bumps [decode-uri-component](https://github.com/SamVerschueren/decode-uri-component) from 0.2.0 to 0.2.2. - [Release notes](https://github.com/SamVerschueren/decode-uri-component/releases) - [Commits](https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.2) --- updated-dependencies: - dependency-name: decode-uri-component dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7f2e9858a..01cb7cfa6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6953,9 +6953,9 @@ decimal.js@^10.2.1: integrity sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ== decode-uri-component@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" - integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= + version "0.2.2" + resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9" + integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ== dedent@0.7.0, dedent@^0.7.0: version "0.7.0" From 1ec6dce4b87cd9873e0bdff15822875cc85ffb71 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Thu, 16 Nov 2023 16:31:11 -0500 Subject: [PATCH 02/18] fallback for when pattern filtering filters all patterns --- lib/actions/apiV2.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/actions/apiV2.js b/lib/actions/apiV2.js index d8de7a73a..7010dac83 100644 --- a/lib/actions/apiV2.js +++ b/lib/actions/apiV2.js @@ -13,8 +13,8 @@ import { generateModeSettingValues } from '../util/api' import { getActiveItineraries, getActiveItinerary, - isValidSubsequence, getRouteOperator, + isValidSubsequence, queryIsValid } from '../util/state' import { getRouteColorBasedOnSettings } from '../util/viewer' @@ -682,7 +682,12 @@ export const findRoute = (params) => }) }) - filteredPatterns.forEach((pattern) => { + // Fallback for if the filtering removes all patterns + // If this happens, it is not possible to know which pattern to keep + ;(filteredPatterns.length > 0 + ? filteredPatterns + : newRoute.patterns + ).forEach((pattern) => { const patternStops = pattern.stops.map((stop) => { const color = stop.routes?.length > 0 && @@ -995,7 +1000,8 @@ export function routingQuery(searchId = null, updateSearchInReducer) { } }) ?.map(convertGraphQLResponseToLegacy) - })) + }) + ) /* It is possible for a NO_TRANSIT_CONNECTION error to be returned even if trips were returned, since it is on a mode-by-mode basis. From 56f43aa60534bba0c4769c2ddff3140480ec04e2 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Fri, 17 Nov 2023 11:17:01 -0500 Subject: [PATCH 03/18] potential approach for restoring auto-highlight behavior --- lib/actions/api.js | 4 --- .../narrative/narrative-itineraries.js | 32 +++++++++++++++++-- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/lib/actions/api.js b/lib/actions/api.js index dafc7cc42..7dafff4d4 100644 --- a/lib/actions/api.js +++ b/lib/actions/api.js @@ -12,7 +12,6 @@ import { getSecureFetchOptions } from '../util/middleware' import { getStopViewerConfig } from '../util/state' import { MainPanelContent } from './ui-constants' -import { setVisibleItinerary } from './narrative' import v1Actions from './apiV1' import v2Actions from './apiV2' @@ -139,9 +138,6 @@ export function updateOtpUrlParams(state, searchId) { params.ui_activeItinerary = -1 // At the same time, reset/delete the ui_itineraryView param. params.ui_itineraryView = undefined - if (config.itinerary?.showFirstResultByDefault) { - dispatch(setVisibleItinerary({ index: 0 })) - } // Merge in the provided OTP params and update the URL. dispatch(setUrlSearch(Object.assign(params, otpParams))) } diff --git a/lib/components/narrative/narrative-itineraries.js b/lib/components/narrative/narrative-itineraries.js index 6d20a2437..80eec5c36 100644 --- a/lib/components/narrative/narrative-itineraries.js +++ b/lib/components/narrative/narrative-itineraries.js @@ -331,13 +331,16 @@ class NarrativeItineraries extends Component { ) } - componentDidUpdate() { + componentDidUpdate(prevProps) { // If set in URL, set the active itinerary in the state, once. const { activeItinerary, activeSearch, + itineraryConfig, + mergedItineraries, setActiveItinerary, - setVisibleItinerary + setVisibleItinerary, + visibleItinerary } = this.props const { ui_activeItinerary: uiActiveItinerary } = coreUtils.query.getUrlParams() || {} @@ -350,6 +353,28 @@ class NarrativeItineraries extends Component { setActiveItinerary({ index: +uiActiveItinerary }) setVisibleItinerary({ index: +uiActiveItinerary }) } + + /** + * Show first result by default is a lot more complicated now that we have + * fixed indeces. We must update the visible itinerary here instead of in the redux state. + * Also, we need to update whenever new items arrive, to make sure that the highlighted + * itinerary is indeed the first one. + * + * Finally, we need to make sure we only update if the data changes, not if the user actually + * highlighted something else on their own. + */ + if (itineraryConfig?.showFirstResultByDefault) { + const firstSortedItin = + mergedItineraries?.length > 0 && mergedItineraries?.[0].index + + if ( + activeItinerary === -1 && + (visibleItinerary === null || visibleItinerary === false) && + prevProps.mergedItineraries.length !== mergedItineraries.length + ) { + setVisibleItinerary({ index: firstSortedItin }) + } + } } // eslint-disable-next-line complexity @@ -531,7 +556,7 @@ const reduceErrorsFromResponse = (acc, cur) => { const mapStateToProps = (state) => { const { config, filter } = state.otp - const { co2, errorMessages, modes } = config + const { co2, errorMessages, itinerary, modes } = config const { sort } = filter const activeSearch = getActiveSearch(state) @@ -590,6 +615,7 @@ const mapStateToProps = (state) => { groupItineraries, groupTransitModes, itineraries: allItineraries, + itineraryConfig: itinerary, itineraryIsExpanded, // use a key so that the NarrativeItineraries component and its state is // reset each time a new search is shown From b12a1327b34e700885fa44e2e875c6ba3e053a33 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Fri, 17 Nov 2023 11:26:21 -0500 Subject: [PATCH 04/18] appease codespell --- lib/components/narrative/narrative-itineraries.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/narrative/narrative-itineraries.js b/lib/components/narrative/narrative-itineraries.js index 80eec5c36..4fa12dbad 100644 --- a/lib/components/narrative/narrative-itineraries.js +++ b/lib/components/narrative/narrative-itineraries.js @@ -356,7 +356,7 @@ class NarrativeItineraries extends Component { /** * Show first result by default is a lot more complicated now that we have - * fixed indeces. We must update the visible itinerary here instead of in the redux state. + * fixed indices. We must update the visible itinerary here instead of in the redux state. * Also, we need to update whenever new items arrive, to make sure that the highlighted * itinerary is indeed the first one. * From e98645abc031d462332e12de3bb35fb95d680503 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Mon, 20 Nov 2023 14:15:13 -0500 Subject: [PATCH 05/18] fix(PhoneNumberEditor): Prevent flashing "Verified" when sending number for verif. --- lib/components/user/phone-number-editor.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/components/user/phone-number-editor.tsx b/lib/components/user/phone-number-editor.tsx index fd5e8b972..6366e5928 100644 --- a/lib/components/user/phone-number-editor.tsx +++ b/lib/components/user/phone-number-editor.tsx @@ -247,9 +247,11 @@ class PhoneNumberEditor extends Component { ) : ( - - - + phoneNumberVerified && ( + + + + ) )} )