From 2c13e4deaafaff0aeabc78cce217078b06200a28 Mon Sep 17 00:00:00 2001 From: Nam Le Date: Wed, 26 Jul 2023 18:31:22 +0700 Subject: [PATCH] fix timezone on profile with new account Signed-off-by: Nam Le --- src/libs/Navigation/AppNavigator/AuthScreens.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index 44294d40387e..8fca9aea495c 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -35,20 +35,21 @@ import styles from '../../../styles/styles'; import * as SessionUtils from '../../SessionUtils'; import getNavigationModalCardStyle from '../../../styles/getNavigationModalCardStyles'; -let currentUserEmail; +let timezone; +let currentAccountID; Onyx.connect({ key: ONYXKEYS.SESSION, callback: (val) => { - // When signed out, val is undefined - if (!val) { + // When signed out, val hasn't accountID + if (!_.has(val, 'accountID')) { + timezone = null; return; } - currentUserEmail = val.email; + currentAccountID = val.accountID; }, }); -let timezone; Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, callback: (val) => { @@ -56,7 +57,7 @@ Onyx.connect({ return; } - timezone = lodashGet(val, [currentUserEmail, 'timezone'], {}); + timezone = lodashGet(val, [currentAccountID, '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