-
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
Changes from 1 commit
0d34efd
073f8f7
9e22ee5
3f587b6
953ca2e
97c20b3
e27a3ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,27 +34,48 @@ class TimezoneSelectPage extends Component { | |
this.saveSelectedTimezone = this.saveSelectedTimezone.bind(this); | ||
this.filterShownTimezones = this.filterShownTimezones.bind(this); | ||
|
||
this.currentSelectedTimezone = lodashGet(props.currentUserPersonalDetails, 'timezone.selected', CONST.DEFAULT_TIME_ZONE.selected); | ||
this.timezone = lodashGet(props.currentUserPersonalDetails, 'timezone', CONST.DEFAULT_TIME_ZONE); | ||
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.currentSelectedTimezone ? greenCheckmark : undefined, | ||
customIcon: timezone === this.timezone.selected ? greenCheckmark : undefined, | ||
|
||
// This property will make the currently selected value have bold text | ||
boldStyle: timezone === this.currentSelectedTimezone, | ||
boldStyle: timezone === this.timezone.selected, | ||
})) | ||
.value(); | ||
|
||
this.state = { | ||
timezoneInputText: this.currentSelectedTimezone, | ||
timezoneInputText: this.timezone.selected, | ||
timezoneOptions: this.allTimezones, | ||
}; | ||
} | ||
|
||
componentDidUpdate() { | ||
// Update timezoneInputText & all timezoneOptions when the timezone object changes | ||
const newTimezone = lodashGet(this.props.currentUserPersonalDetails, 'timezone', CONST.DEFAULT_TIME_ZONE); | ||
if (_.isEqual(this.timezone, newTimezone)) { return; } | ||
this.timezone = newTimezone; | ||
const updatedAllTimezones = _.map(this.allTimezones, timezone => ({ | ||
...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.setState({ | ||
timezoneInputText: this.timezone.selected, | ||
timezoneOptions: updatedAllTimezones, | ||
}); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @priyeshshah11 Why do we need this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @priyeshshah11 that will help to explain what's going on 👍 |
||
|
||
/** | ||
* @param {Object} timezone | ||
* @param {String} timezone.text | ||
|
@@ -90,7 +111,7 @@ class TimezoneSelectPage extends Component { | |
onChangeText={this.filterShownTimezones} | ||
onSelectRow={this.saveSelectedTimezone} | ||
optionHoveredStyle={styles.hoveredComponentBG} | ||
sections={[{data: this.state.timezoneOptions}]} | ||
sections={[{data: this.state.timezoneOptions, isDisabled: this.timezone.automatic}]} | ||
shouldHaveOptionSeparator | ||
safeAreaPaddingBottomStyle={safeAreaPaddingBottomStyle} | ||
/> | ||
|
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.