Ver código fonte

Moves native password required prompt to room lock feature.

Moves native dialogs to use dialog container. Implements native Dialog that uses react native Prompt.
j8
damencho 8 anos atrás
pai
commit
309ce43e05

+ 1
- 104
react/features/conference/components/Conference.native.js Ver arquivo

@@ -6,10 +6,8 @@ import { DialogContainer } from '../../base/dialog';
6 6
 import { Container } from '../../base/react';
7 7
 import { FilmStrip } from '../../film-strip';
8 8
 import { LargeVideo } from '../../large-video';
9
-import { RoomLockPrompt } from '../../room-lock';
10 9
 import { Toolbar } from '../../toolbar';
11 10
 
12
-import PasswordRequiredPrompt from './PasswordRequiredPrompt';
13 11
 import { styles } from './styles';
14 12
 
15 13
 /**
@@ -30,23 +28,6 @@ class Conference extends Component {
30 28
      * @static
31 29
      */
32 30
     static propTypes = {
33
-        /**
34
-         * The indicator which determines whether a password is required to join
35
-         * the conference and has not been provided yet.
36
-         *
37
-         * @private
38
-         * @type {JitsiConference}
39
-         */
40
-        _passwordRequired: React.PropTypes.object,
41
-
42
-        /**
43
-         * The indicator which determines whether the user has requested to lock
44
-         * the conference/room.
45
-         *
46
-         * @private
47
-         * @type {JitsiConference}
48
-         */
49
-        _roomLockRequested: React.PropTypes.object,
50 31
         dispatch: React.PropTypes.func
51 32
     }
52 33
 
@@ -128,9 +109,6 @@ class Conference extends Component {
128 109
 
129 110
                 <DialogContainer />
130 111
 
131
-                {
132
-                    this._renderPrompt()
133
-                }
134 112
             </Container>
135 113
         );
136 114
     }
@@ -164,56 +142,6 @@ class Conference extends Component {
164 142
         this._setToolbarTimeout(toolbarVisible);
165 143
     }
166 144
 
167
-    /**
168
-     * Renders a prompt if a password is required to join the conference.
169
-     *
170
-     * @private
171
-     * @returns {ReactElement}
172
-     */
173
-    _renderPasswordRequiredPrompt() {
174
-        const required = this.props._passwordRequired;
175
-
176
-        if (required) {
177
-            return (
178
-                <PasswordRequiredPrompt conference = { required } />
179
-            );
180
-        }
181
-
182
-        return null;
183
-    }
184
-
185
-    /**
186
-     * Renders a prompt if necessary such as when a password is required to join
187
-     * the conference or the user has requested to lock the conference/room.
188
-     *
189
-     * @private
190
-     * @returns {ReactElement}
191
-     */
192
-    _renderPrompt() {
193
-        return (
194
-            this._renderPasswordRequiredPrompt()
195
-                || this._renderRoomLockPrompt()
196
-        );
197
-    }
198
-
199
-    /**
200
-     * Renders a prompt if the user has requested to lock the conference/room.
201
-     *
202
-     * @private
203
-     * @returns {ReactElement}
204
-     */
205
-    _renderRoomLockPrompt() {
206
-        const requested = this.props._roomLockRequested;
207
-
208
-        if (requested) {
209
-            return (
210
-                <RoomLockPrompt conference = { requested } />
211
-            );
212
-        }
213
-
214
-        return null;
215
-    }
216
-
217 145
     /**
218 146
      * Triggers the default toolbar timeout.
219 147
      *
@@ -231,35 +159,4 @@ class Conference extends Component {
231 159
     }
232 160
 }
233 161
 
234
-/**
235
- * Maps (parts of) the Redux state to the associated Conference's props.
236
- *
237
- * @param {Object} state - The Redux state.
238
- * @private
239
- * @returns {{
240
- *     _passwordRequired: boolean
241
- * }}
242
- */
243
-function _mapStateToProps(state) {
244
-    return {
245
-        /**
246
-         * The indicator which determines whether a password is required to join
247
-         * the conference and has not been provided yet.
248
-         *
249
-         * @private
250
-         * @type {JitsiConference}
251
-         */
252
-        _passwordRequired: state['features/base/conference'].passwordRequired,
253
-
254
-        /**
255
-         * The indicator which determines whether the user has requested to lock
256
-         * the conference/room.
257
-         *
258
-         * @private
259
-         * @type {JitsiConference}
260
-         */
261
-        _roomLockRequested: state['features/room-lock'].requested
262
-    };
263
-}
264
-
265
-export default reactReduxConnect(_mapStateToProps)(Conference);
162
+export default reactReduxConnect()(Conference);

+ 0
- 24
react/features/room-lock/actionTypes.js Ver arquivo

@@ -1,24 +0,0 @@
1
-import { Symbol } from '../base/react';
2
-
3
-/**
4
- * The type of Redux action which begins a (user) request to lock a specific
5
- * JitsiConference.
6
- *
7
- * {
8
- *     type: BEGIN_ROOM_LOCK_REQUEST,
9
- *     conference: JitsiConference
10
- * }
11
- */
12
-export const BEGIN_ROOM_LOCK_REQUEST = Symbol('BEGIN_ROOM_LOCK_REQUEST');
13
-
14
-/**
15
- * The type of Redux action which end a (user) request to lock a specific
16
- * JitsiConference.
17
- *
18
- * {
19
- *     type: END_ROOM_LOCK_REQUEST,
20
- *     conference: JitsiConference,
21
- *     password: string
22
- * }
23
- */
24
-export const END_ROOM_LOCK_REQUEST = Symbol('END_ROOM_LOCK_REQUEST');

+ 5
- 14
react/features/room-lock/actions.js Ver arquivo

@@ -1,8 +1,6 @@
1 1
 import { setPassword } from '../base/conference';
2
-import { openDialog } from '../base/dialog';
3
-import { PasswordRequiredPrompt } from './components';
4
-
5
-import { BEGIN_ROOM_LOCK_REQUEST, END_ROOM_LOCK_REQUEST } from './actionTypes';
2
+import { hideDialog, openDialog } from '../base/dialog';
3
+import { PasswordRequiredPrompt, RoomLockPrompt } from './components';
6 4
 
7 5
 /**
8 6
  * Begins a (user) request to lock a specific conference/room.
@@ -21,10 +19,7 @@ export function beginRoomLockRequest(conference) {
21 19
         }
22 20
 
23 21
         if (conference) {
24
-            dispatch({
25
-                type: BEGIN_ROOM_LOCK_REQUEST,
26
-                conference
27
-            });
22
+            dispatch(openDialog(RoomLockPrompt, { conference }));
28 23
         }
29 24
     };
30 25
 }
@@ -45,11 +40,7 @@ export function endRoomLockRequest(conference, password) {
45 40
                 ? dispatch(setPassword(conference, conference.lock, password))
46 41
                 : Promise.resolve();
47 42
         const endRoomLockRequest_ = () => {
48
-            dispatch({
49
-                type: END_ROOM_LOCK_REQUEST,
50
-                conference,
51
-                password
52
-            });
43
+            dispatch(hideDialog());
53 44
         };
54 45
 
55 46
         setPassword_.then(endRoomLockRequest_, endRoomLockRequest_);
@@ -63,7 +54,7 @@ export function endRoomLockRequest(conference, password) {
63 54
  * requesting password.
64 55
  * @protected
65 56
  * @returns {{
66
- *     type: BEGIN_DIALOG_REQUEST,
57
+ *     type: OPEN_DIALOG,
67 58
  *     component: Component,
68 59
  *     props: React.PropTypes
69 60
  * }}

react/features/conference/components/PasswordRequiredPrompt.native.js → react/features/room-lock/components/PasswordRequiredPrompt.native.js Ver arquivo

@@ -1,9 +1,8 @@
1 1
 import React, { Component } from 'react';
2
-import Prompt from 'react-native-prompt';
3 2
 import { connect } from 'react-redux';
3
+import { Dialog } from '../../base/dialog';
4 4
 
5 5
 import { setPassword } from '../../base/conference';
6
-import { translate } from '../../base/i18n';
7 6
 
8 7
 /**
9 8
  * Implements a React Component which prompts the user when a password is
@@ -22,15 +21,7 @@ class PasswordRequiredPrompt extends Component {
22 21
          * @type {JitsiConference}
23 22
          */
24 23
         conference: React.PropTypes.object,
25
-        dispatch: React.PropTypes.func,
26
-
27
-        /**
28
-         * The function to translate human-readable text.
29
-         *
30
-         * @public
31
-         * @type {Function}
32
-         */
33
-        t: React.PropTypes.func
24
+        dispatch: React.PropTypes.func
34 25
     }
35 26
 
36 27
     /**
@@ -54,15 +45,13 @@ class PasswordRequiredPrompt extends Component {
54 45
      * @returns {ReactElement}
55 46
      */
56 47
     render() {
57
-        const { t } = this.props;
58 48
 
59 49
         return (
60
-            <Prompt
50
+            <Dialog
51
+                bodyKey = 'dialog.passwordLabel'
61 52
                 onCancel = { this._onCancel }
62 53
                 onSubmit = { this._onSubmit }
63
-                placeholder = { t('dialog.passwordLabel') }
64
-                title = { t('dialog.passwordRequired') }
65
-                visible = { true } />
54
+                titleKey = 'dialog.passwordRequired' />
66 55
         );
67 56
     }
68 57
 
@@ -70,14 +59,14 @@ class PasswordRequiredPrompt extends Component {
70 59
      * Notifies this prompt that it has been dismissed by cancel.
71 60
      *
72 61
      * @private
73
-     * @returns {void}
62
+     * @returns {boolean} whether to hide dialog.
74 63
      */
75 64
     _onCancel() {
76 65
         // XXX The user has canceled this prompt for a password so we are to
77 66
         // attempt joining the conference without a password. If the conference
78 67
         // still requires a password to join, the user will be prompted again
79 68
         // later.
80
-        this._onSubmit(undefined);
69
+        return this._onSubmit(undefined);
81 70
     }
82 71
 
83 72
     /**
@@ -86,13 +75,15 @@ class PasswordRequiredPrompt extends Component {
86 75
      *
87 76
      * @param {string} value - The submitted value.
88 77
      * @private
89
-     * @returns {void}
78
+     * @returns {boolean} whether to hide dialog.
90 79
      */
91 80
     _onSubmit(value) {
92 81
         const conference = this.props.conference;
93 82
 
94 83
         this.props.dispatch(setPassword(conference, conference.join, value));
84
+
85
+        return true;
95 86
     }
96 87
 }
97 88
 
98
-export default translate(connect()(PasswordRequiredPrompt));
89
+export default connect()(PasswordRequiredPrompt);

+ 14
- 21
react/features/room-lock/components/RoomLockPrompt.native.js Ver arquivo

@@ -1,8 +1,6 @@
1 1
 import React, { Component } from 'react';
2
-import Prompt from 'react-native-prompt';
3 2
 import { connect } from 'react-redux';
4
-
5
-import { translate } from '../../base/i18n';
3
+import { Dialog } from '../../base/dialog';
6 4
 
7 5
 import { endRoomLockRequest } from '../actions';
8 6
 
@@ -23,15 +21,7 @@ class RoomLockPrompt extends Component {
23 21
          * @type {JitsiConference}
24 22
          */
25 23
         conference: React.PropTypes.object,
26
-        dispatch: React.PropTypes.func,
27
-
28
-        /**
29
-         * The function to translate human-readable text.
30
-         *
31
-         * @public
32
-         * @type {Function}
33
-         */
34
-        t: React.PropTypes.func
24
+        dispatch: React.PropTypes.func
35 25
     }
36 26
 
37 27
     /**
@@ -55,15 +45,13 @@ class RoomLockPrompt extends Component {
55 45
      * @returns {ReactElement}
56 46
      */
57 47
     render() {
58
-        const { t } = this.props;
59 48
 
60 49
         return (
61
-            <Prompt
50
+            <Dialog
51
+                bodyKey = 'dialog.passwordLabel'
62 52
                 onCancel = { this._onCancel }
63 53
                 onSubmit = { this._onSubmit }
64
-                placeholder = { t('dialog.passwordLabel') }
65
-                title = { t('toolbar.lock') }
66
-                visible = { true } />
54
+                titleKey = 'toolbar.lock' />
67 55
         );
68 56
     }
69 57
 
@@ -71,12 +59,12 @@ class RoomLockPrompt extends Component {
71 59
      * Notifies this prompt that it has been dismissed by cancel.
72 60
      *
73 61
      * @private
74
-     * @returns {void}
62
+     * @returns {boolean} whether to hide the dialog
75 63
      */
76 64
     _onCancel() {
77 65
         // An undefined password is understood to cancel the request to lock the
78 66
         // conference/room.
79
-        this._onSubmit(undefined);
67
+        return this._onSubmit(undefined);
80 68
     }
81 69
 
82 70
     /**
@@ -85,11 +73,16 @@ class RoomLockPrompt extends Component {
85 73
      *
86 74
      * @param {string} value - The submitted value.
87 75
      * @private
88
-     * @returns {void}
76
+     * @returns {boolean} returns false, we do not want to hide dialog as this
77
+     * will be handled inside endRoomLockRequest after setting password is
78
+     * resolved.
89 79
      */
90 80
     _onSubmit(value) {
91 81
         this.props.dispatch(endRoomLockRequest(this.props.conference, value));
82
+
83
+        // do not hide
84
+        return false;
92 85
     }
93 86
 }
94 87
 
95
-export default translate(connect()(RoomLockPrompt));
88
+export default connect()(RoomLockPrompt);

+ 0
- 1
react/features/room-lock/index.js Ver arquivo

@@ -2,4 +2,3 @@ export * from './actions';
2 2
 export * from './components';
3 3
 
4 4
 import './middleware';
5
-import './reducer';

+ 0
- 33
react/features/room-lock/reducer.js Ver arquivo

@@ -1,33 +0,0 @@
1
-import {
2
-    CONFERENCE_FAILED,
3
-    CONFERENCE_JOINED,
4
-    CONFERENCE_LEFT
5
-} from '../base/conference';
6
-import { ReducerRegistry, setStateProperty } from '../base/redux';
7
-
8
-import { BEGIN_ROOM_LOCK_REQUEST, END_ROOM_LOCK_REQUEST } from './actionTypes';
9
-
10
-ReducerRegistry.register('features/room-lock', (state = {}, action) => {
11
-    switch (action.type) {
12
-    case BEGIN_ROOM_LOCK_REQUEST:
13
-        return setStateProperty(state, 'requested', action.conference);
14
-
15
-    case CONFERENCE_FAILED:
16
-    case CONFERENCE_LEFT:
17
-    case END_ROOM_LOCK_REQUEST: {
18
-        if (state.requested === action.conference) {
19
-            return setStateProperty(state, 'requested', undefined);
20
-        }
21
-        break;
22
-    }
23
-
24
-    case CONFERENCE_JOINED: {
25
-        if (state.requested !== action.conference) {
26
-            return setStateProperty(state, 'requested', undefined);
27
-        }
28
-        break;
29
-    }
30
-    }
31
-
32
-    return state;
33
-});

Carregando…
Cancelar
Salvar