Procházet zdrojové kódy

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

master
Дамян Минков před 4 roky
rodič
revize
bcc326c150

+ 35
- 9
react/features/participants-pane/components/web/MeetingParticipantList.js Zobrazit soubor

@@ -2,13 +2,14 @@
2 2
 
3 3
 import React, { useCallback, useRef, useState } from 'react';
4 4
 import { useTranslation } from 'react-i18next';
5
-import { useSelector, useDispatch } from 'react-redux';
5
+import { useDispatch } from 'react-redux';
6 6
 
7 7
 import { openDialog } from '../../../base/dialog';
8 8
 import {
9 9
     getParticipantCountWithFake,
10 10
     getSortedParticipantIds
11 11
 } from '../../../base/participants';
12
+import { connect } from '../../../base/redux';
12 13
 import MuteRemoteParticipantDialog from '../../../video-menu/components/web/MuteRemoteParticipantDialog';
13 14
 import { findStyledAncestor, shouldRenderInviteButton } from '../../functions';
14 15
 
@@ -25,7 +26,7 @@ type NullProto = {
25 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 31
   offsetTarget?: HTMLElement,
31 32
 
@@ -39,19 +40,18 @@ const initialState = Object.freeze(Object.create(null));
39 40
 
40 41
 /**
41 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 49
  * @returns {ReactNode} - The component.
44 50
  */
45
-export function MeetingParticipantList() {
51
+function MeetingParticipantList({ participantsCount, showInviteButton, sortedParticipantIds = [] }) {
46 52
     const dispatch = useDispatch();
47 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 55
     const [ raiseContext, setRaiseContext ] = useState<RaiseContext>(initialState);
56 56
     const { t } = useTranslation();
57 57
 
@@ -144,3 +144,29 @@ export function MeetingParticipantList() {
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 Zobrazit soubor

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

Načítá se…
Zrušit
Uložit