Explorar el Código

invite: remove duplicated code

Add ability to invite users which will use the share sheet or dialog
dynamically.
master
Saúl Ibarra Corretgé hace 5 años
padre
commit
cdc14586de

+ 2
- 19
react/features/conference/components/native/LonelyMeetingExperience.js Ver fichero

4
 import { Text, TouchableOpacity, View } from 'react-native';
4
 import { Text, TouchableOpacity, View } from 'react-native';
5
 
5
 
6
 import { ColorSchemeRegistry } from '../../../base/color-scheme';
6
 import { ColorSchemeRegistry } from '../../../base/color-scheme';
7
-import { getFeatureFlag, INVITE_ENABLED } from '../../../base/flags';
8
 import { connect } from '../../../base/redux';
7
 import { connect } from '../../../base/redux';
9
 import { StyleType } from '../../../base/styles';
8
 import { StyleType } from '../../../base/styles';
10
 import { translate } from '../../../base/i18n';
9
 import { translate } from '../../../base/i18n';
11
 import { getParticipantCount } from '../../../base/participants';
10
 import { getParticipantCount } from '../../../base/participants';
12
-import { isAddPeopleEnabled, isDialOutEnabled, setAddPeopleDialogVisible } from '../../../invite';
13
-import { beginShareRoom } from '../../../share-room';
11
+import { doInvitePeople } from '../../../invite/actions.native';
14
 
12
 
15
 import styles from './styles';
13
 import styles from './styles';
16
 import { Icon, IconAddPeople } from '../../../base/icons';
14
 import { Icon, IconAddPeople } from '../../../base/icons';
20
  */
18
  */
21
 type Props = {
19
 type Props = {
22
 
20
 
23
-    /**
24
-     * True if any of the invite functions are enabled.
25
-     */
26
-    _inviteEnabled: boolean,
27
-
28
     /**
21
     /**
29
      * True if it's a lonely meeting (participant count excluding fakes is 1).
22
      * True if it's a lonely meeting (participant count excluding fakes is 1).
30
      */
23
      */
112
      * @returns {void}
105
      * @returns {void}
113
      */
106
      */
114
     _onPress() {
107
     _onPress() {
115
-        const { _inviteEnabled, dispatch } = this.props;
116
-
117
-        if (_inviteEnabled) {
118
-            dispatch(setAddPeopleDialogVisible(true));
119
-        } else {
120
-            dispatch(beginShareRoom());
121
-        }
108
+        this.props.dispatch(doInvitePeople());
122
     }
109
     }
123
 }
110
 }
124
 
111
 
130
  * @returns {Props}
117
  * @returns {Props}
131
  */
118
  */
132
 function _mapStateToProps(state): $Shape<Props> {
119
 function _mapStateToProps(state): $Shape<Props> {
133
-    const _inviteEnabled = getFeatureFlag(state, INVITE_ENABLED, true)
134
-        && (isAddPeopleEnabled(state) || isDialOutEnabled(state));
135
-
136
     return {
120
     return {
137
-        _inviteEnabled,
138
         _isLonelyMeeting: getParticipantCount(state) === 1,
121
         _isLonelyMeeting: getParticipantCount(state) === 1,
139
         _styles: ColorSchemeRegistry.get(state, 'Conference')
122
         _styles: ColorSchemeRegistry.get(state, 'Conference')
140
     };
123
     };

react/features/invite/actions.js → react/features/invite/actions.any.js Ver fichero


+ 31
- 0
react/features/invite/actions.native.js Ver fichero

1
+// @flow
2
+
3
+import type { Dispatch } from 'redux';
4
+
5
+import { getFeatureFlag, INVITE_ENABLED } from '../base/flags';
6
+import { beginShareRoom } from '../share-room';
7
+
8
+import { setAddPeopleDialogVisible } from './actions.any';
9
+import { isAddPeopleEnabled, isDialOutEnabled } from './functions';
10
+
11
+export * from './actions.any';
12
+
13
+/**
14
+ * Starts the process for inviting people. Dpending on the sysstem config it
15
+ * may use the system share sheet or the invite peoplee dialog.
16
+ *
17
+ * @returns {Function}
18
+ */
19
+export function doInvitePeople() {
20
+    return (dispatch: Dispatch<any>, getState: Function) => {
21
+        const state = getState();
22
+        const addPeopleEnabled = getFeatureFlag(state, INVITE_ENABLED, true)
23
+            && (isAddPeopleEnabled(state) || isDialOutEnabled(state));
24
+
25
+        if (addPeopleEnabled) {
26
+            return dispatch(setAddPeopleDialogVisible(true));
27
+        }
28
+
29
+        return dispatch(beginShareRoom());
30
+    };
31
+}

+ 1
- 0
react/features/invite/actions.web.js Ver fichero

1
+export * from './actions.any';

+ 1
- 1
react/features/invite/components/add-people-dialog/native/AddPeopleDialog.js Ver fichero

24
 } from '../../../../base/react';
24
 } from '../../../../base/react';
25
 import { connect } from '../../../../base/redux';
25
 import { connect } from '../../../../base/redux';
26
 
26
 
27
-import { setAddPeopleDialogVisible } from '../../../actions';
27
+import { setAddPeopleDialogVisible } from '../../../actions.native';
28
 
28
 
29
 import AbstractAddPeopleDialog, {
29
 import AbstractAddPeopleDialog, {
30
     type Props as AbstractProps,
30
     type Props as AbstractProps,

+ 3
- 33
react/features/invite/components/add-people-dialog/native/InviteButton.js Ver fichero

2
 
2
 
3
 import type { Dispatch } from 'redux';
3
 import type { Dispatch } from 'redux';
4
 
4
 
5
-import { getFeatureFlag, INVITE_ENABLED } from '../../../../base/flags';
6
 import { translate } from '../../../../base/i18n';
5
 import { translate } from '../../../../base/i18n';
7
 import { IconAddPeople } from '../../../../base/icons';
6
 import { IconAddPeople } from '../../../../base/icons';
8
 import { connect } from '../../../../base/redux';
7
 import { connect } from '../../../../base/redux';
9
 import { AbstractButton } from '../../../../base/toolbox';
8
 import { AbstractButton } from '../../../../base/toolbox';
10
 import type { AbstractButtonProps } from '../../../../base/toolbox';
9
 import type { AbstractButtonProps } from '../../../../base/toolbox';
11
-import { beginShareRoom } from '../../../../share-room';
12
 
10
 
13
-import { setAddPeopleDialogVisible } from '../../../actions';
14
-import { isAddPeopleEnabled, isDialOutEnabled } from '../../../functions';
11
+import { doInvitePeople } from '../../../actions.native';
15
 
12
 
16
 type Props = AbstractButtonProps & {
13
 type Props = AbstractButtonProps & {
17
 
14
 
18
-    /**
19
-     * Whether the (backend) add people feature is enabled or not.
20
-     */
21
-    _addPeopleEnabled: boolean,
22
-
23
     /**
15
     /**
24
      * The Redux dispatch function.
16
      * The Redux dispatch function.
25
      */
17
      */
42
      * @returns {void}
34
      * @returns {void}
43
      */
35
      */
44
     _handleClick() {
36
     _handleClick() {
45
-        const { _addPeopleEnabled, dispatch } = this.props;
46
-
47
-        if (_addPeopleEnabled) {
48
-            dispatch(setAddPeopleDialogVisible(true));
49
-        } else {
50
-            dispatch(beginShareRoom());
51
-        }
37
+        this.props.dispatch(doInvitePeople());
52
     }
38
     }
53
 }
39
 }
54
 
40
 
55
-/**
56
- * Maps (parts of) the redux state to {@link InviteButton}'s React {@code Component}
57
- * props.
58
- *
59
- * @param {Object} state - The redux store/state.
60
- * @private
61
- * @returns {Object}
62
- */
63
-function _mapStateToProps(state: Object) {
64
-    const addPeopleEnabled = getFeatureFlag(state, INVITE_ENABLED, true)
65
-        && (isAddPeopleEnabled(state) || isDialOutEnabled(state));
66
-
67
-    return {
68
-        _addPeopleEnabled: addPeopleEnabled
69
-    };
70
-}
71
 
41
 
72
-export default translate(connect(_mapStateToProps)(InviteButton));
42
+export default translate(connect()(InviteButton));

+ 1
- 1
react/features/toolbox/components/native/OverflowMenu.js Ver fichero

6
 
6
 
7
 import { ColorSchemeRegistry } from '../../../base/color-scheme';
7
 import { ColorSchemeRegistry } from '../../../base/color-scheme';
8
 import { BottomSheet, hideDialog, isDialogOpen } from '../../../base/dialog';
8
 import { BottomSheet, hideDialog, isDialogOpen } from '../../../base/dialog';
9
-import { IconDragHandle } from '../../../base/icons';
10
 import { IOS_RECORDING_ENABLED, getFeatureFlag } from '../../../base/flags';
9
 import { IOS_RECORDING_ENABLED, getFeatureFlag } from '../../../base/flags';
10
+import { IconDragHandle } from '../../../base/icons';
11
 import { connect } from '../../../base/redux';
11
 import { connect } from '../../../base/redux';
12
 import { StyleType } from '../../../base/styles';
12
 import { StyleType } from '../../../base/styles';
13
 import { SharedDocumentButton } from '../../../etherpad';
13
 import { SharedDocumentButton } from '../../../etherpad';

Loading…
Cancelar
Guardar