Przeglądaj źródła

invite: remove duplicated code

Add ability to invite users which will use the share sheet or dialog
dynamically.
master
Saúl Ibarra Corretgé 5 lat temu
rodzic
commit
cdc14586de

+ 2
- 19
react/features/conference/components/native/LonelyMeetingExperience.js Wyświetl plik

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

react/features/invite/actions.js → react/features/invite/actions.any.js Wyświetl plik


+ 31
- 0
react/features/invite/actions.native.js Wyświetl plik

@@ -0,0 +1,31 @@
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 Wyświetl plik

@@ -0,0 +1 @@
1
+export * from './actions.any';

+ 1
- 1
react/features/invite/components/add-people-dialog/native/AddPeopleDialog.js Wyświetl plik

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

+ 3
- 33
react/features/invite/components/add-people-dialog/native/InviteButton.js Wyświetl plik

@@ -2,24 +2,16 @@
2 2
 
3 3
 import type { Dispatch } from 'redux';
4 4
 
5
-import { getFeatureFlag, INVITE_ENABLED } from '../../../../base/flags';
6 5
 import { translate } from '../../../../base/i18n';
7 6
 import { IconAddPeople } from '../../../../base/icons';
8 7
 import { connect } from '../../../../base/redux';
9 8
 import { AbstractButton } from '../../../../base/toolbox';
10 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 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 16
      * The Redux dispatch function.
25 17
      */
@@ -42,31 +34,9 @@ class InviteButton extends AbstractButton<Props, *> {
42 34
      * @returns {void}
43 35
      */
44 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 Wyświetl plik

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

Ładowanie…
Anuluj
Zapisz