Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix timezone on profile with new account #23631

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming from #48941, we missed that the currentAccountID isn't actually cleared in the case a user deletes their account. This can cause a loop of trying to update the timezone which never resolves because the update timezone call's error (due to the account no longer existing) isn't handled.

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
Loading