|
@@ -14,6 +14,11 @@ import { _cancelPasswordRequiredPrompt } from '../actions';
|
14
|
14
|
*/
|
15
|
15
|
type Props = {
|
16
|
16
|
|
|
17
|
+ /**
|
|
18
|
+ * The previously entered password, if any.
|
|
19
|
+ */
|
|
20
|
+ _password: ?string,
|
|
21
|
+
|
17
|
22
|
/**
|
18
|
23
|
* The {@code JitsiConference} which requires a password.
|
19
|
24
|
*
|
|
@@ -27,11 +32,19 @@ type Props = {
|
27
|
32
|
dispatch: Dispatch<any>
|
28
|
33
|
};
|
29
|
34
|
|
|
35
|
+type State = {
|
|
36
|
+
|
|
37
|
+ /**
|
|
38
|
+ * The previously entered password, if any.
|
|
39
|
+ */
|
|
40
|
+ password: ?string
|
|
41
|
+}
|
|
42
|
+
|
30
|
43
|
/**
|
31
|
44
|
* Implements a React {@code Component} which prompts the user when a password
|
32
|
45
|
* is required to join a conference.
|
33
|
46
|
*/
|
34
|
|
-class PasswordRequiredPrompt extends Component<Props> {
|
|
47
|
+class PasswordRequiredPrompt extends Component<Props, State> {
|
35
|
48
|
/**
|
36
|
49
|
* Initializes a new {@code PasswordRequiredPrompt} instance.
|
37
|
50
|
*
|
|
@@ -41,11 +54,34 @@ class PasswordRequiredPrompt extends Component<Props> {
|
41
|
54
|
constructor(props: Props) {
|
42
|
55
|
super(props);
|
43
|
56
|
|
|
57
|
+ this.state = {
|
|
58
|
+ password: props._password
|
|
59
|
+ };
|
|
60
|
+
|
44
|
61
|
// Bind event handlers so they are only bound once per instance.
|
45
|
62
|
this._onCancel = this._onCancel.bind(this);
|
46
|
63
|
this._onSubmit = this._onSubmit.bind(this);
|
47
|
64
|
}
|
48
|
65
|
|
|
66
|
+ /**
|
|
67
|
+ * Implements {@code Component#componentDidUpdate}.
|
|
68
|
+ *
|
|
69
|
+ * @inheritdoc
|
|
70
|
+ */
|
|
71
|
+ componentDidUpdate() {
|
|
72
|
+ const { _password } = this.props;
|
|
73
|
+
|
|
74
|
+ // The previous password in Redux gets cleared after the dialog appears and it ends up breaking the dialog
|
|
75
|
+ // logic. We move the prop into state and only update it if it has an actual value, avoiding loosing the
|
|
76
|
+ // previously received value when Redux updates.
|
|
77
|
+ if (_password && _password !== this.state.password) {
|
|
78
|
+ // eslint-disable-next-line react/no-did-update-set-state
|
|
79
|
+ this.setState({
|
|
80
|
+ password: _password
|
|
81
|
+ });
|
|
82
|
+ }
|
|
83
|
+ }
|
|
84
|
+
|
49
|
85
|
/**
|
50
|
86
|
* Implements React's {@link Component#render()}.
|
51
|
87
|
*
|
|
@@ -53,9 +89,13 @@ class PasswordRequiredPrompt extends Component<Props> {
|
53
|
89
|
* @returns {ReactElement}
|
54
|
90
|
*/
|
55
|
91
|
render() {
|
|
92
|
+ const { password } = this.state;
|
|
93
|
+
|
56
|
94
|
return (
|
57
|
95
|
<InputDialog
|
58
|
96
|
contentKey = 'dialog.passwordLabel'
|
|
97
|
+ initialValue = { password }
|
|
98
|
+ messageKey = { password ? 'dialog.incorrectRoomLockPassword' : undefined }
|
59
|
99
|
onCancel = { this._onCancel }
|
60
|
100
|
onSubmit = { this._onSubmit }
|
61
|
101
|
textInputProps = {{
|
|
@@ -100,4 +140,16 @@ class PasswordRequiredPrompt extends Component<Props> {
|
100
|
140
|
}
|
101
|
141
|
}
|
102
|
142
|
|
103
|
|
-export default connect()(PasswordRequiredPrompt);
|
|
143
|
+/**
|
|
144
|
+ * Maps part of the Redux state to the props of this component.
|
|
145
|
+ *
|
|
146
|
+ * @param {Object} state - The Redux state.
|
|
147
|
+ * @returns {Props}
|
|
148
|
+ */
|
|
149
|
+function _mapStateToProps(state) {
|
|
150
|
+ return {
|
|
151
|
+ _password: state['features/base/conference'].password
|
|
152
|
+ };
|
|
153
|
+}
|
|
154
|
+
|
|
155
|
+export default connect(_mapStateToProps)(PasswordRequiredPrompt);
|