Skip to content

Commit

Permalink
Merge pull request #23631 from namhihi237/fix-23479-profile-timezone
Browse files Browse the repository at this point in the history
fix timezone on profile with new account
  • Loading branch information
Beamanator authored Jul 27, 2023
2 parents ffd7636 + 2c13e4d commit ac74ab9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,29 @@ 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) => {
if (!val || timezone) {
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
Expand Down

0 comments on commit ac74ab9

Please sign in to comment.