|
@@ -112,6 +112,28 @@ type State = {
|
112
|
112
|
class InfoDialog extends Component<Props, State> {
|
113
|
113
|
_copyElement: ?Object;
|
114
|
114
|
|
|
115
|
+ /**
|
|
116
|
+ * Implements React's {@link Component#getDerivedStateFromProps()}.
|
|
117
|
+ *
|
|
118
|
+ * @inheritdoc
|
|
119
|
+ */
|
|
120
|
+ static getDerivedStateFromProps(props, state) {
|
|
121
|
+ let phoneNumber = state.phoneNumber;
|
|
122
|
+
|
|
123
|
+ if (!state.phoneNumber && props.dialIn.numbers) {
|
|
124
|
+ const { defaultCountry, numbers } = props.dialIn;
|
|
125
|
+
|
|
126
|
+ phoneNumber = _getDefaultPhoneNumber(numbers, defaultCountry);
|
|
127
|
+ }
|
|
128
|
+
|
|
129
|
+ return {
|
|
130
|
+ // Exit edit mode when a password is set locally or remotely.
|
|
131
|
+ passwordEditEnabled: state.passwordEditEnabled && props._password
|
|
132
|
+ ? false : state.passwordEditEnabled,
|
|
133
|
+ phoneNumber
|
|
134
|
+ };
|
|
135
|
+ }
|
|
136
|
+
|
115
|
137
|
/**
|
116
|
138
|
* {@code InfoDialog} component's local state.
|
117
|
139
|
*
|
|
@@ -162,28 +184,6 @@ class InfoDialog extends Component<Props, State> {
|
162
|
184
|
this._setCopyElement = this._setCopyElement.bind(this);
|
163
|
185
|
}
|
164
|
186
|
|
165
|
|
- /**
|
166
|
|
- * Implements React's {@link Component#componentWillReceiveProps()}. Invoked
|
167
|
|
- * before this mounted component receives new props.
|
168
|
|
- *
|
169
|
|
- * @inheritdoc
|
170
|
|
- * @param {Props} nextProps - New props component will receive.
|
171
|
|
- */
|
172
|
|
- componentWillReceiveProps(nextProps) {
|
173
|
|
- if (!this.props._password && nextProps._password) {
|
174
|
|
- this.setState({ passwordEditEnabled: false });
|
175
|
|
- }
|
176
|
|
-
|
177
|
|
- if (!this.state.phoneNumber && nextProps.dialIn.numbers) {
|
178
|
|
- const { defaultCountry, numbers } = nextProps.dialIn;
|
179
|
|
-
|
180
|
|
- this.setState({
|
181
|
|
- phoneNumber:
|
182
|
|
- _getDefaultPhoneNumber(numbers, defaultCountry)
|
183
|
|
- });
|
184
|
|
- }
|
185
|
|
- }
|
186
|
|
-
|
187
|
187
|
/**
|
188
|
188
|
* Implements React's {@link Component#render()}.
|
189
|
189
|
*
|