diff --git a/lib/actions/apiV2.js b/lib/actions/apiV2.js index d1e1b82e4..a9e1deb57 100644 --- a/lib/actions/apiV2.js +++ b/lib/actions/apiV2.js @@ -26,6 +26,7 @@ import { import { getRouteColorBasedOnSettings, getRouteIdForPattern, + getRouteTextColorBasedOnSettings, routeIsValid } from '../util/viewer' import { isLastStop } from '../util/stop-times' @@ -1130,20 +1131,30 @@ export function routingQuery(searchId = null, updateSearchInReducer) { ...itin, legs: itin.legs ?.map((leg) => { + const routeOperator = getRouteOperator( + { + agencyId: leg?.agency?.id, + id: leg?.route?.id + }, + config.transitOperators + ) + const routeProperties = { + color: leg?.route?.color, + mode: leg.mode + } + return { ...leg, origColor: leg?.route?.color, route: { ...leg.route, color: getRouteColorBasedOnSettings( - getRouteOperator( - { - agencyId: leg?.agency?.id, - id: leg?.route?.id - }, - config.transitOperators - ), - { color: leg?.route?.color, mode: leg.mode } + routeOperator, + routeProperties + ).split('#')?.[1], + textColor: getRouteTextColorBasedOnSettings( + routeOperator, + routeProperties ).split('#')?.[1] } } diff --git a/lib/util/viewer.js b/lib/util/viewer.js index e5bcd85a2..c3d026486 100644 --- a/lib/util/viewer.js +++ b/lib/util/viewer.js @@ -355,6 +355,10 @@ export function getRouteColorBasedOnSettings(operator = {}, route = {}) { return backgroundColor } } +export function getRouteTextColorBasedOnSettings(operator = {}, route = {}) { + const { color } = getColorAndNameFromRoute(operator, route) + return color +} /** * Helper method to determine if a stop being viewed is a flex stop. This is not marked by