Skip to content

Commit

Permalink
Merge pull request #1062 from opentripplanner/set-locale-on-login
Browse files Browse the repository at this point in the history
fix(actions/user): Apply persisted preferredLocale on login, if any.
  • Loading branch information
binh-dam-ibigroup authored Dec 11, 2023
2 parents a18d451 + fb68991 commit 4cfbc1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/actions/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { isBlank } from '../util/ui'
import { secureFetch } from '../util/middleware'
import { TRIPS_PATH } from '../util/constants'

import { routeTo } from './ui'
import { routeTo, setLocale } from './ui'
import { routingQuery } from './api'
import { setQueryParam } from './form'

Expand Down Expand Up @@ -232,7 +232,8 @@ export function fetchTripRequests() {
/**
* Updates the redux state with the provided user data, including
* placing the Home and Work locations at the beginning of the list
* of saved places for rendering in several UI components.
* of saved places for rendering in several UI components,
* and applying accessibility and locale settings.
*
* Also, fetches monitored trips if requested, i.e. when
* - initializing the user state with an existing persisted user, or
Expand All @@ -248,10 +249,13 @@ function setUser(user, fetchTrips) {
dispatch(fetchTripRequests())
}

const { accessibilityRoutingByDefault } = user
const { accessibilityRoutingByDefault, preferredLocale } = user
if (accessibilityRoutingByDefault !== undefined) {
dispatch(setQueryParam({ wheelchair: accessibilityRoutingByDefault }))
}
if (!isBlank(preferredLocale)) {
dispatch(setLocale(preferredLocale))
}
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/components/user/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface User {
mobilityProfile?: MobilityProfile
notificationChannel?: string
phoneNumber?: string
preferredLocale?: string
pushDevices?: number
savedLocations?: UserSavedLocation[]
storeTripHistory?: boolean
Expand Down

0 comments on commit 4cfbc1a

Please sign in to comment.