From a4ba5ee6a36f4c9f7f598ce3907086fb5f8fe58d Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Thu, 21 Jul 2022 12:44:53 +0200 Subject: [PATCH 1/3] Enclose lodash path params in array --- src/libs/DateUtils.js | 4 +++- src/libs/Navigation/AppNavigator/AuthScreens.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/DateUtils.js b/src/libs/DateUtils.js index 522b2500a519..7f6fc2e6c8fe 100644 --- a/src/libs/DateUtils.js +++ b/src/libs/DateUtils.js @@ -29,7 +29,7 @@ let timezone = CONST.DEFAULT_TIME_ZONE; Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS, callback: (val) => { - timezone = lodashGet(val, currentUserEmail, 'timezone', CONST.DEFAULT_TIME_ZONE); + timezone = lodashGet(val, [currentUserEmail, 'timezone'], CONST.DEFAULT_TIME_ZONE); }, }); @@ -68,6 +68,8 @@ function getLocalMomentFromTimestamp(locale, timestamp, currentSelectedTimezone * @returns {String} */ function timestampToDateTime(locale, timestamp, includeTimeZone = false) { + console.log({locale, timestamp, includeTimeZone}) + debugger; const date = getLocalMomentFromTimestamp(locale, timestamp); const tz = includeTimeZone ? ' [UTC]Z' : ''; diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index 29deef79a250..4779e0ae1ca9 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -57,7 +57,7 @@ Onyx.connect({ return; } - const timezone = lodashGet(val, currentUserEmail, 'timezone', {}); + const timezone = lodashGet(val, [currentUserEmail, 'timezone'], {}); const currentTimezone = moment.tz.guess(true); // If the current timezone is different than the user's timezone, and their timezone is set to automatic From 2927760bb865becad1eb6bfd0a9b936462b25d3d Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Thu, 21 Jul 2022 12:45:16 +0200 Subject: [PATCH 2/3] Move timezone prop to path for safety --- src/pages/settings/Profile/ProfilePage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/settings/Profile/ProfilePage.js b/src/pages/settings/Profile/ProfilePage.js index 0f99d722b5ba..0cdde430ee2c 100755 --- a/src/pages/settings/Profile/ProfilePage.js +++ b/src/pages/settings/Profile/ProfilePage.js @@ -75,8 +75,8 @@ class ProfilePage extends Component { pronouns: this.props.currentUserPersonalDetails.pronouns, hasPronounError: false, hasSelfSelectedPronouns: !_.isEmpty(this.props.currentUserPersonalDetails.pronouns) && !this.props.currentUserPersonalDetails.pronouns.startsWith(CONST.PRONOUNS.PREFIX), - selectedTimezone: lodashGet(this.props.currentUserPersonalDetails.timezone, 'selected', CONST.DEFAULT_TIME_ZONE.selected), - isAutomaticTimezone: lodashGet(this.props.currentUserPersonalDetails.timezone, 'automatic', CONST.DEFAULT_TIME_ZONE.automatic), + selectedTimezone: lodashGet(this.props.currentUserPersonalDetails, 'timezone.selected', CONST.DEFAULT_TIME_ZONE.selected), + isAutomaticTimezone: lodashGet(this.props.currentUserPersonalDetails, 'timezone.automatic', CONST.DEFAULT_TIME_ZONE.automatic), logins: this.getLogins(props.loginList), avatar: {uri: lodashGet(this.props.currentUserPersonalDetails, 'avatar', ReportUtils.getDefaultAvatar(this.props.currentUserPersonalDetails.login))}, isAvatarChanged: false, From 6aaa98a64b0029bb70d3e1d06dc689afcdf14b24 Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Thu, 21 Jul 2022 12:48:16 +0200 Subject: [PATCH 3/3] Remove testing code --- src/libs/DateUtils.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/DateUtils.js b/src/libs/DateUtils.js index 7f6fc2e6c8fe..1f02c98657db 100644 --- a/src/libs/DateUtils.js +++ b/src/libs/DateUtils.js @@ -68,8 +68,6 @@ function getLocalMomentFromTimestamp(locale, timestamp, currentSelectedTimezone * @returns {String} */ function timestampToDateTime(locale, timestamp, includeTimeZone = false) { - console.log({locale, timestamp, includeTimeZone}) - debugger; const date = getLocalMomentFromTimestamp(locale, timestamp); const tz = includeTimeZone ? ' [UTC]Z' : '';