Просмотр исходного кода

fix: Fixes undefined errors in MeetingParticipant - Item and ContextMenu.

master
Дамян Минков 4 лет назад
Родитель
Сommit
bcc326c150

+ 35
- 9
react/features/participants-pane/components/web/MeetingParticipantList.js Просмотреть файл

2
 
2
 
3
 import React, { useCallback, useRef, useState } from 'react';
3
 import React, { useCallback, useRef, useState } from 'react';
4
 import { useTranslation } from 'react-i18next';
4
 import { useTranslation } from 'react-i18next';
5
-import { useSelector, useDispatch } from 'react-redux';
5
+import { useDispatch } from 'react-redux';
6
 
6
 
7
 import { openDialog } from '../../../base/dialog';
7
 import { openDialog } from '../../../base/dialog';
8
 import {
8
 import {
9
     getParticipantCountWithFake,
9
     getParticipantCountWithFake,
10
     getSortedParticipantIds
10
     getSortedParticipantIds
11
 } from '../../../base/participants';
11
 } from '../../../base/participants';
12
+import { connect } from '../../../base/redux';
12
 import MuteRemoteParticipantDialog from '../../../video-menu/components/web/MuteRemoteParticipantDialog';
13
 import MuteRemoteParticipantDialog from '../../../video-menu/components/web/MuteRemoteParticipantDialog';
13
 import { findStyledAncestor, shouldRenderInviteButton } from '../../functions';
14
 import { findStyledAncestor, shouldRenderInviteButton } from '../../functions';
14
 
15
 
25
 type RaiseContext = NullProto | {|
26
 type RaiseContext = NullProto | {|
26
 
27
 
27
   /**
28
   /**
28
-   * Target elements against which positioning calculations are made
29
+   * Target elements against which positioning calculations are made.
29
    */
30
    */
30
   offsetTarget?: HTMLElement,
31
   offsetTarget?: HTMLElement,
31
 
32
 
39
 
40
 
40
 /**
41
 /**
41
  * Renders the MeetingParticipantList component.
42
  * Renders the MeetingParticipantList component.
43
+ * NOTE: This component is not using useSelector on purpose. The child components MeetingParticipantItem
44
+ * and MeetingParticipantContextMenu are using connect. Having those mixed leads to problems.
45
+ * When this one was using useSelector and the other two were not -the other two were re-rendered before this one was
46
+ * re-rendered, so when participant is leaving, we first re-render the item and menu components,
47
+ * throwing errors (closing the page) before removing those components for the participant that left.
42
  *
48
  *
43
  * @returns {ReactNode} - The component.
49
  * @returns {ReactNode} - The component.
44
  */
50
  */
45
-export function MeetingParticipantList() {
51
+function MeetingParticipantList({ participantsCount, showInviteButton, sortedParticipantIds = [] }) {
46
     const dispatch = useDispatch();
52
     const dispatch = useDispatch();
47
     const isMouseOverMenu = useRef(false);
53
     const isMouseOverMenu = useRef(false);
48
-    const sortedParticipantIds = useSelector(getSortedParticipantIds);
49
 
54
 
50
-    // This is very important as getRemoteParticipants is not changing its reference object
51
-    // and we will not re-render on change, but if count changes we will do
52
-    const participantsCount = useSelector(getParticipantCountWithFake);
53
-
54
-    const showInviteButton = useSelector(shouldRenderInviteButton);
55
     const [ raiseContext, setRaiseContext ] = useState<RaiseContext>(initialState);
55
     const [ raiseContext, setRaiseContext ] = useState<RaiseContext>(initialState);
56
     const { t } = useTranslation();
56
     const { t } = useTranslation();
57
 
57
 
144
     </>
144
     </>
145
     );
145
     );
146
 }
146
 }
147
+
148
+/**
149
+ * Maps (parts of) the redux state to the associated props for this component.
150
+ *
151
+ * @param {Object} state - The Redux state.
152
+ * @param {Object} ownProps - The own props of the component.
153
+ * @private
154
+ * @returns {Props}
155
+ */
156
+function _mapStateToProps(state): Object {
157
+    const sortedParticipantIds = getSortedParticipantIds(state);
158
+
159
+    // This is very important as getRemoteParticipants is not changing its reference object
160
+    // and we will not re-render on change, but if count changes we will do
161
+    const participantsCount = getParticipantCountWithFake(state);
162
+
163
+    const showInviteButton = shouldRenderInviteButton(state);
164
+
165
+    return {
166
+        sortedParticipantIds,
167
+        participantsCount,
168
+        showInviteButton
169
+    };
170
+}
171
+
172
+export default connect(_mapStateToProps)(MeetingParticipantList);

+ 1
- 1
react/features/participants-pane/components/web/ParticipantsPane.js Просмотреть файл

14
 import { FooterContextMenu } from '../FooterContextMenu';
14
 import { FooterContextMenu } from '../FooterContextMenu';
15
 
15
 
16
 import { LobbyParticipantList } from './LobbyParticipantList';
16
 import { LobbyParticipantList } from './LobbyParticipantList';
17
-import { MeetingParticipantList } from './MeetingParticipantList';
17
+import MeetingParticipantList from './MeetingParticipantList';
18
 import {
18
 import {
19
     AntiCollapse,
19
     AntiCollapse,
20
     Close,
20
     Close,

Загрузка…
Отмена
Сохранить