[MM-18765] remove lifecycle methods from settings (#4596)
This commit is contained in:
parent
27849beed4
commit
18d1dcbc09
3 changed files with 22 additions and 48 deletions
|
|
@ -17,41 +17,11 @@ export default class RadioButtonGroup extends PureComponent {
|
|||
options: [],
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
selected: this.getSelectedValue(props.options),
|
||||
};
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.options !== nextProps.options) {
|
||||
this.setState({selected: this.getSelectedValue(nextProps.options)});
|
||||
}
|
||||
}
|
||||
|
||||
getSelectedValue = (options = []) => {
|
||||
let selected;
|
||||
for (const option in options) {
|
||||
if (option.checked) {
|
||||
selected = option.value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return selected;
|
||||
}
|
||||
|
||||
onChange = (value) => {
|
||||
const {onSelect} = this.props;
|
||||
this.setState({
|
||||
selected: value,
|
||||
}, () => {
|
||||
if (onSelect) {
|
||||
onSelect(value);
|
||||
}
|
||||
});
|
||||
if (onSelect) {
|
||||
onSelect(value);
|
||||
}
|
||||
};
|
||||
|
||||
render = () => {
|
||||
|
|
|
|||
|
|
@ -40,10 +40,10 @@ export default class NotificationSettings extends PureComponent {
|
|||
intl: intlShape.isRequired,
|
||||
};
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const {updateMeRequest} = nextProps;
|
||||
componentDidUpdate(prevProps) {
|
||||
const {updateMeRequest} = this.props;
|
||||
const {intl} = this.context;
|
||||
if (this.props.updateMeRequest !== updateMeRequest && updateMeRequest.status === RequestStatus.FAILURE) {
|
||||
if (prevProps.updateMeRequest.status !== updateMeRequest.status && updateMeRequest.status === RequestStatus.FAILURE) {
|
||||
Alert.alert(
|
||||
intl.formatMessage({
|
||||
id: 'mobile.notification_settings.save_failed_title',
|
||||
|
|
|
|||
|
|
@ -44,19 +44,29 @@ export default class NotificationSettingsEmailBase extends PureComponent {
|
|||
this.navigationEventListener = Navigation.events().bindComponent(this);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
componentDidDisappear() {
|
||||
if (this.getPlatformOS() === 'ios') {
|
||||
this.saveEmailNotifyProps();
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
this.setEmailIntervalIfNeeded(prevProps);
|
||||
}
|
||||
|
||||
setEmailIntervalIfNeeded = (prevProps) => {
|
||||
const {
|
||||
notifyProps,
|
||||
sendEmailNotifications,
|
||||
enableEmailBatching,
|
||||
emailInterval,
|
||||
} = nextProps;
|
||||
} = this.props;
|
||||
|
||||
if (
|
||||
this.props.sendEmailNotifications !== sendEmailNotifications ||
|
||||
this.props.enableEmailBatching !== enableEmailBatching ||
|
||||
this.props.emailInterval !== emailInterval ||
|
||||
this.props.notifyProps?.email !== notifyProps?.email
|
||||
sendEmailNotifications !== prevProps.sendEmailNotifications ||
|
||||
enableEmailBatching !== prevProps.enableEmailBatching ||
|
||||
emailInterval !== prevProps.emailInterval ||
|
||||
notifyProps?.email !== prevProps.notifyProps?.email
|
||||
) {
|
||||
this.setState({
|
||||
emailInterval,
|
||||
|
|
@ -65,12 +75,6 @@ export default class NotificationSettingsEmailBase extends PureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
componentDidDisappear() {
|
||||
if (this.getPlatformOS() === 'ios') {
|
||||
this.saveEmailNotifyProps();
|
||||
}
|
||||
}
|
||||
|
||||
getPlatformOS = () => {
|
||||
return Platform.OS;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue