-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Disables timezone options if it is set to automatic #15176
Disables timezone options if it is set to automatic #15176
Conversation
There's a bug I found while testing this PR. Whenever I redirect to the select timezone page with automatic set to Simulator.Screen.Recording.-.iPhone.13.-.2023-02-16.at.22.06.07.mp4Also, I confirm this already in staging, so no regression tied to this PR. |
Reviewer Checklist
Screenshots/VideosWeb15176.Web.mp4Mobile Web - Chrome15176.mWeb-Chrome.mp4Mobile Web - Safari15176.mWeb-Safari.mp4Desktop15176.Desktop.mp4iOS15176.iOS.mp4Android15176.Android.mp4 |
timezoneInputText: this.timezone.selected, | ||
timezoneOptions: updatedAllTimezones, | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@priyeshshah11 Why do we need this componentDidUpdate
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also adds componentDidUpdate in order to update the timezone options when automatic is toggled on/off as navigating back doesn't unmount the page, thus it won't update the timezone options & stay disabled without this.
We should put that instead of // Update timezoneInputText & all timezoneOptions when the timezone object changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also adds componentDidUpdate in order to update the timezone options when automatic is toggled on/off as navigating back doesn't unmount the page, thus it won't update the timezone options & stay disabled without this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @priyeshshah11 that will help to explain what's going on 👍
Assigning @tylerkaraszewski since a bug caused me to be added to #14340 by mistake, but Tyler is CME on that GH, not me |
// componentDidUpdate is added in order to update the timezone options when automatic is toggled on/off as | ||
// navigating back doesn't unmount the page, thus it won't update the timezone options & stay disabled without this. | ||
const newTimezone = lodashGet(this.props.currentUserPersonalDetails, 'timezone', CONST.DEFAULT_TIME_ZONE); | ||
if (_.isEqual(this.timezone, newTimezone)) { return; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (_.isEqual(this.timezone, newTimezone)) { return; } | |
if (_.isEqual(this.timezone, newTimezone)) { | |
return; | |
} | |
@priyeshshah11 Is it possible to DRY the below codes?
Example: getUserTimezone(currentUserPersonalDetails) {
return lodashGet(currentUserPersonalDetails, 'timezone', CONST.DEFAULT_TIME_ZONE);
}
formatTimezone(timezone) {
return {
text: timezone,
keyForList: timezone,
// Include the green checkmark icon to indicate the currently selected value
customIcon: timezone === this.timezone.selected ? greenCheckmark : undefined,
// This property will make the currently selected value have bold text
boldStyle: timezone === this.timezone.selected,
};
} - this.timezone = lodashGet(props.currentUserPersonalDetails, 'timezone', CONST.DEFAULT_TIME_ZONE);
+ this.timezone = this.getUserTimezone(props.currentUserPersonalDetails);
this.allTimezones = _.chain(moment.tz.names())
.filter(timezone => !timezone.startsWith('Etc/GMT'))
- .map(timezone => ({
- text: timezone,
- keyForList: timezone,
-
- // Include the green checkmark icon to indicate the currently selected value
- customIcon: timezone === this.timezone.selected ? greenCheckmark : undefined,
-
- // This property will make the currently selected value have bold text
- boldStyle: timezone === this.timezone.selected,
- }))
+ .map(this.formatTimezone)
.value();
this.state = {
@@ -58,23 +49,36 @@ class TimezoneSelectPage extends Component {
componentDidUpdate() {
// componentDidUpdate is added in order to update the timezone options when automatic is toggled on/off as
// navigating back doesn't unmount the page, thus it won't update the timezone options & stay disabled without this.
- const newTimezone = lodashGet(this.props.currentUserPersonalDetails, 'timezone', CONST.DEFAULT_TIME_ZONE);
- if (_.isEqual(this.timezone, newTimezone)) { return; }
+ const newTimezone = this.getUserTimezone(this.props.currentUserPersonalDetails);
+ if (_.isEqual(this.timezone, newTimezone)) {
+ return;
+ }
+
this.timezone = newTimezone;
- const updatedAllTimezones = _.map(this.allTimezones, timezone => ({
- ...timezone,
+ const updatedAllTimezones = _.map(this.allTimezones, this.formatTimezone);
+
+ this.setState({
+ timezoneInputText: this.timezone.selected,
+ timezoneOptions: updatedAllTimezones,
+ });
+ } |
@mollfpr Thanks for that suggestion. I have refactored the get timezone part but not the Thus, I have refactored it to use the correct type of data in each Let me know your thoughts on those changes! Thanks 😄 |
Sorry, I didn't mean to remove the review request for @tylerkaraszewski but re-requesting review from @mollfpr did it automatically & now I can't request from Tyler. |
*/ | ||
getKey(text) { | ||
return `${text}-${(new Date()).getTime()}`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a description of why we are doing this?
|
||
// This property will make the currently selected value have bold text | ||
boldStyle: text === this.timezone.selected, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a similar object structured within the constructor. We could probably create a function to return the object with a single argument.
Thanks for the update @priyeshshah11! It solves the issue I encountered before, just left with a comment. |
@mollfpr Done, refactored as requested 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@mollfpr @tylerkaraszewski Are we waiting on anything here? Is there any action required from me? |
@priyeshshah11 we just need to wait for @tylerkaraszewski to review this. |
@priyeshshah11 Could you resolve the conflict? Thanks! |
Done @mollfpr |
Bump @tylerkaraszewski for final review. |
Bump @tylerkaraszewski for review. |
Congrats, that’s your 5th PR merged! 🎉 Do you know about the ContributorPlus role? It’s an opportunity to earn more in the Expensify Open Source community. Keep up the great work - thanks! |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Performance Comparison Report 📊Significant Changes To Duration
Show details
Meaningless Changes To DurationShow entries
Show details
|
@Expensify/mobile-deployers 📣 Please look into this performance regression as it's a deploy blocker. |
🚀 Deployed to staging by https://github.com/tylerkaraszewski in version: 1.2.78-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.2.78-0 🚀
|
This regression was caused by this PR.
|
Details
This PR disables all the timezone options in the list if timezone is set to automatic. It also adds
componentDidUpdate
in order to update the timezone options when automatic is toggled on/off as navigating back doesn't unmount the page, thus it won't update the timezone options & stay disabled without this.Fixed Issues
$ #14340
PROPOSAL: #14340 (comment)
Tests
/select
to the existing route in the browser.Offline tests
You won't be able to go to the timezone options page by modifying the URL in offline mode
QA Steps
Same as Tests section
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.Screenshots/Videos
Web
Screen.Recording.2023-02-16.at.4.03.10.AM.mov
Mobile Web - Chrome
timezone-chrome.mov
timzone-chrom-a.mov
Mobile Web - Safari
timezone-mweb.mov
Desktop
timezone-desktop.mov
iOS
timezone-ios.mov
Android
timezone-android.mov