|
@@ -1,25 +1,14 @@
|
1
|
1
|
// @flow
|
2
|
2
|
|
3
|
|
-import React, { useCallback } from 'react';
|
4
|
|
-import { useTranslation } from 'react-i18next';
|
5
|
|
-import { Text, View } from 'react-native';
|
|
3
|
+import React, { PureComponent } from 'react';
|
|
4
|
+import { FlatList, Text, View } from 'react-native';
|
6
|
5
|
import { Button } from 'react-native-paper';
|
7
|
|
-import { useDispatch, useSelector } from 'react-redux';
|
8
|
|
-
|
9
|
6
|
|
|
7
|
+import { translate } from '../../../base/i18n';
|
10
|
8
|
import { Icon, IconInviteMore } from '../../../base/icons';
|
11
|
|
-import {
|
12
|
|
- getLocalParticipant,
|
13
|
|
- getParticipantCountWithFake,
|
14
|
|
- getSortedParticipants
|
15
|
|
-} from '../../../base/participants';
|
|
9
|
+import { getLocalParticipant, getParticipantCountWithFake } from '../../../base/participants';
|
16
|
10
|
import { connect } from '../../../base/redux';
|
17
|
11
|
import { doInvitePeople } from '../../../invite/actions.native';
|
18
|
|
-import {
|
19
|
|
- showConnectionStatus,
|
20
|
|
- showContextMenuDetails,
|
21
|
|
- showSharedVideoMenu
|
22
|
|
-} from '../../actions.native';
|
23
|
12
|
import { shouldRenderInviteButton } from '../../functions';
|
24
|
13
|
|
25
|
14
|
import MeetingParticipantItem from './MeetingParticipantItem';
|
|
@@ -28,74 +17,150 @@ import styles from './styles';
|
28
|
17
|
type Props = {
|
29
|
18
|
|
30
|
19
|
/**
|
31
|
|
- * Shared video local participant owner.
|
|
20
|
+ * The ID of the local participant.
|
|
21
|
+ */
|
|
22
|
+ _localParticipantId: string,
|
|
23
|
+
|
|
24
|
+ /**
|
|
25
|
+ * The number of participants in the conference.
|
|
26
|
+ */
|
|
27
|
+ _participantsCount: number,
|
|
28
|
+
|
|
29
|
+ /**
|
|
30
|
+ * Whether or not to show the invite button.
|
|
31
|
+ */
|
|
32
|
+ _showInviteButton: boolean,
|
|
33
|
+
|
|
34
|
+ /**
|
|
35
|
+ * The remote participants.
|
32
|
36
|
*/
|
33
|
|
- _localVideoOwner: boolean
|
|
37
|
+ _sortedRemoteParticipants: Map<string, string>,
|
|
38
|
+
|
|
39
|
+ /**
|
|
40
|
+ * The redux dispatch function.
|
|
41
|
+ */
|
|
42
|
+ dispatch: Function,
|
|
43
|
+
|
|
44
|
+ /**
|
|
45
|
+ * Translation function.
|
|
46
|
+ */
|
|
47
|
+ t: Function
|
34
|
48
|
}
|
35
|
49
|
|
36
|
|
-const MeetingParticipantList = ({ _localVideoOwner }: Props) => {
|
37
|
|
- const dispatch = useDispatch();
|
38
|
|
- const onInvite = useCallback(() => dispatch(doInvitePeople()), [ dispatch ]);
|
39
|
|
- const participantsCount = useSelector(getParticipantCountWithFake);
|
40
|
|
- const sortedParticipants = useSelector(getSortedParticipants);
|
41
|
|
- const showInviteButton = useSelector(shouldRenderInviteButton);
|
42
|
|
- const { t } = useTranslation();
|
43
|
|
-
|
44
|
|
- // eslint-disable-next-line react/no-multi-comp
|
45
|
|
- const renderParticipant = p => {
|
46
|
|
- if (p.isFakeParticipant) {
|
47
|
|
- if (_localVideoOwner) {
|
48
|
|
- return (
|
49
|
|
- <MeetingParticipantItem
|
50
|
|
- key = { p.id }
|
51
|
|
- /* eslint-disable-next-line react/jsx-no-bind,no-confusing-arrow */
|
52
|
|
- onPress = { () => dispatch(showSharedVideoMenu(p)) }
|
53
|
|
- participantID = { p.id } />
|
54
|
|
- );
|
55
|
|
- }
|
56
|
|
-
|
57
|
|
- return (
|
58
|
|
- <MeetingParticipantItem
|
59
|
|
- key = { p.id }
|
60
|
|
- participantID = { p.id } />
|
61
|
|
- );
|
62
|
|
- }
|
|
50
|
+/**
|
|
51
|
+ * The meeting participant list component.
|
|
52
|
+ */
|
|
53
|
+class MeetingParticipantList extends PureComponent<Props> {
|
|
54
|
+
|
|
55
|
+ /**
|
|
56
|
+ * Creates new MeetingParticipantList instance.
|
|
57
|
+ *
|
|
58
|
+ * @param {Props} props - The props of the component.
|
|
59
|
+ */
|
|
60
|
+ constructor(props: Props) {
|
|
61
|
+ super(props);
|
|
62
|
+
|
|
63
|
+ this._keyExtractor = this._keyExtractor.bind(this);
|
|
64
|
+ this._onInvite = this._onInvite.bind(this);
|
|
65
|
+ this._renderParticipant = this._renderParticipant.bind(this);
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ _keyExtractor: Function;
|
63
|
69
|
|
|
70
|
+ /**
|
|
71
|
+ * Returns a key for a passed item of the list.
|
|
72
|
+ *
|
|
73
|
+ * @param {string} item - The user ID.
|
|
74
|
+ * @returns {string} - The user ID.
|
|
75
|
+ */
|
|
76
|
+ _keyExtractor(item) {
|
|
77
|
+ return item;
|
|
78
|
+ }
|
|
79
|
+
|
|
80
|
+ _onInvite: () => void;
|
|
81
|
+
|
|
82
|
+ /**
|
|
83
|
+ * Handles ivite button presses.
|
|
84
|
+ *
|
|
85
|
+ * @returns {void}
|
|
86
|
+ */
|
|
87
|
+ _onInvite() {
|
|
88
|
+ this.props.dispatch(doInvitePeople());
|
|
89
|
+ }
|
|
90
|
+
|
|
91
|
+ /**
|
|
92
|
+ * Renders the "invite more" icon.
|
|
93
|
+ *
|
|
94
|
+ * @returns {ReactElement}
|
|
95
|
+ */
|
|
96
|
+ _renderInviteMoreIcon() {
|
|
97
|
+ return (
|
|
98
|
+ <Icon
|
|
99
|
+ size = { 20 }
|
|
100
|
+ src = { IconInviteMore } />
|
|
101
|
+ );
|
|
102
|
+ }
|
|
103
|
+
|
|
104
|
+ _renderParticipant: Object => Object;
|
|
105
|
+
|
|
106
|
+ /**
|
|
107
|
+ * Renders a participant.
|
|
108
|
+ *
|
|
109
|
+ * @param {Object} flatListItem - Information about the item to be rendered.
|
|
110
|
+ * @param {string} flatListItem.item - The ID of the participant.
|
|
111
|
+ * @returns {ReactElement}
|
|
112
|
+ */
|
|
113
|
+ _renderParticipant({ item/* , index, separators */ }) {
|
64
|
114
|
return (
|
65
|
115
|
<MeetingParticipantItem
|
66
|
|
- key = { p.id }
|
67
|
|
- /* eslint-disable-next-line react/jsx-no-bind,no-confusing-arrow */
|
68
|
|
- onPress = { () => p.local
|
69
|
|
- ? dispatch(showConnectionStatus(p.id)) : dispatch(showContextMenuDetails(p)) }
|
70
|
|
- participantID = { p.id } />
|
|
116
|
+ key = { item }
|
|
117
|
+ participantID = { item } />
|
71
|
118
|
);
|
72
|
|
- };
|
|
119
|
+ }
|
73
|
120
|
|
74
|
|
- return (
|
75
|
|
- <View style = { styles.meetingList }>
|
76
|
|
- <Text style = { styles.meetingListDescription }>
|
77
|
|
- {t('participantsPane.headings.participantsList',
|
78
|
|
- { count: participantsCount })}
|
79
|
|
- </Text>
|
80
|
|
- {
|
81
|
|
- showInviteButton
|
82
|
|
- && <Button
|
83
|
|
- children = { t('participantsPane.actions.invite') }
|
84
|
|
- /* eslint-disable-next-line react/jsx-no-bind */
|
85
|
|
- icon = { () =>
|
86
|
|
- (<Icon
|
87
|
|
- size = { 20 }
|
88
|
|
- src = { IconInviteMore } />)
|
89
|
|
- }
|
90
|
|
- labelStyle = { styles.inviteLabel }
|
91
|
|
- mode = 'contained'
|
92
|
|
- onPress = { onInvite }
|
93
|
|
- style = { styles.inviteButton } />
|
94
|
|
- }
|
95
|
|
- { sortedParticipants.map(renderParticipant) }
|
96
|
|
- </View>
|
97
|
|
- );
|
98
|
|
-};
|
|
121
|
+ /**
|
|
122
|
+ * Implements React's {@link Component#render()}.
|
|
123
|
+ *
|
|
124
|
+ * @inheritdoc
|
|
125
|
+ * @returns {ReactElement}
|
|
126
|
+ */
|
|
127
|
+ render() {
|
|
128
|
+ const {
|
|
129
|
+ _localParticipantId,
|
|
130
|
+ _participantsCount,
|
|
131
|
+ _showInviteButton,
|
|
132
|
+ _sortedRemoteParticipants,
|
|
133
|
+ t
|
|
134
|
+ } = this.props;
|
|
135
|
+
|
|
136
|
+ return (
|
|
137
|
+ <View style = { styles.meetingList }>
|
|
138
|
+ <Text style = { styles.meetingListDescription }>
|
|
139
|
+ {t('participantsPane.headings.participantsList',
|
|
140
|
+ { count: _participantsCount })}
|
|
141
|
+ </Text>
|
|
142
|
+ {
|
|
143
|
+ _showInviteButton
|
|
144
|
+ && <Button
|
|
145
|
+ children = { t('participantsPane.actions.invite') }
|
|
146
|
+ icon = { this._renderInviteMoreIcon }
|
|
147
|
+ labelStyle = { styles.inviteLabel }
|
|
148
|
+ mode = 'contained'
|
|
149
|
+ onPress = { this._onInvite }
|
|
150
|
+ style = { styles.inviteButton } />
|
|
151
|
+ }
|
|
152
|
+ <FlatList
|
|
153
|
+ bounces = { false }
|
|
154
|
+ data = { [ _localParticipantId, ..._sortedRemoteParticipants ] }
|
|
155
|
+ horizontal = { false }
|
|
156
|
+ keyExtractor = { this._keyExtractor }
|
|
157
|
+ renderItem = { this._renderParticipant }
|
|
158
|
+ showsHorizontalScrollIndicator = { false }
|
|
159
|
+ windowSize = { 2 } />
|
|
160
|
+ </View>
|
|
161
|
+ );
|
|
162
|
+ }
|
|
163
|
+}
|
99
|
164
|
|
100
|
165
|
/**
|
101
|
166
|
* Maps (parts of) the redux state to the associated props for this component.
|
|
@@ -105,12 +170,16 @@ const MeetingParticipantList = ({ _localVideoOwner }: Props) => {
|
105
|
170
|
* @returns {Props}
|
106
|
171
|
*/
|
107
|
172
|
function _mapStateToProps(state): Object {
|
108
|
|
- const { ownerId } = state['features/shared-video'];
|
109
|
|
- const localParticipantId = getLocalParticipant(state).id;
|
|
173
|
+ const _participantsCount = getParticipantCountWithFake(state);
|
|
174
|
+ const { remoteParticipants } = state['features/filmstrip'];
|
|
175
|
+ const _showInviteButton = shouldRenderInviteButton(state);
|
110
|
176
|
|
111
|
177
|
return {
|
112
|
|
- _localVideoOwner: Boolean(ownerId === localParticipantId)
|
|
178
|
+ _participantsCount,
|
|
179
|
+ _showInviteButton,
|
|
180
|
+ _sortedRemoteParticipants: remoteParticipants,
|
|
181
|
+ _localParticipantId: getLocalParticipant(state)?.id
|
113
|
182
|
};
|
114
|
183
|
}
|
115
|
184
|
|
116
|
|
-export default connect(_mapStateToProps)(MeetingParticipantList);
|
|
185
|
+export default translate(connect(_mapStateToProps)(MeetingParticipantList));
|