diff --git a/src/libs/DateUtils.js b/src/libs/DateUtils.js index 1ffe14c5e9ec..a4741d4aa31c 100644 --- a/src/libs/DateUtils.js +++ b/src/libs/DateUtils.js @@ -1,4 +1,5 @@ import moment from 'moment-timezone'; +import lodashGet from 'lodash/get'; // IMPORTANT: load any locales (other than english) that might be passed to moment.locale() import 'moment/locale/es'; @@ -10,11 +11,11 @@ import CONST from '../CONST'; import {translate} from './translate'; import * as PersonalDetails from './actions/PersonalDetails'; -let timezone; +let timezone = CONST.DEFAULT_TIME_ZONE; Onyx.connect({ key: ONYXKEYS.MY_PERSONAL_DETAILS, callback: (val) => { - timezone = val ? val.timezone : CONST.DEFAULT_TIME_ZONE; + timezone = lodashGet(val, 'timezone', CONST.DEFAULT_TIME_ZONE); }, }); diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index b6bc0b1314f8..5338f4cb283d 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -173,7 +173,7 @@ class AuthScreens extends React.Component { returnValueList: 'nameValuePairs', nvpNames: ONYXKEYS.NVP_PREFERRED_LOCALE, }).then((response) => { - const preferredLocale = response.nameValuePairs.preferredLocale || CONST.DEFAULT_LOCALE; + const preferredLocale = lodashGet(response, ['nameValuePairs', 'preferredLocale'], CONST.DEFAULT_LOCALE); if ((currentPreferredLocale !== CONST.DEFAULT_LOCALE) && (preferredLocale !== currentPreferredLocale)) { setLocale(currentPreferredLocale); } else {