Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(participants-pane/native): fix participants sort (#13997)
Calinteodor0d572b3bfb10
diff --git a/react/features/base/participants/functions.ts b/react/features/base/participants/functions.tsindex 38e1d228b1..4ce216ed81 100644--- a/react/features/base/participants/functions.ts+++ b/react/features/base/participants/functions.ts@@ -818,7 +818,7 @@ export const addPeopleFeatureControl = (stateful: IStateful) => {* @param {Function} dispatch - The Redux dispatch function.* @returns {Function}*/-export const setShareDialogVisiblity = (addPeopleFeatureEnabled: boolean, dispatch: IStore['dispatch']) => {+export const setShareDialogVisiblity = (addPeopleFeatureEnabled: boolean | undefined, dispatch: IStore['dispatch']) => {if (addPeopleFeatureEnabled) {dispatch(toggleShareDialog(false));} else {diff --git a/react/features/participants-pane/components/native/MeetingParticipantItem.tsx b/react/features/participants-pane/components/native/MeetingParticipantItem.tsxindex 980ef11042..7c400dcb13 100644--- a/react/features/participants-pane/components/native/MeetingParticipantItem.tsx+++ b/react/features/participants-pane/components/native/MeetingParticipantItem.tsx@@ -1,8 +1,7 @@-import React, { PureComponent } from 'react';-import { connect } from 'react-redux';+import React, { useCallback } from 'react';+import { connect, useDispatch } from 'react-redux';-import { IReduxState, IStore } from '../../../app/types';-import { translate } from '../../../base/i18n/functions';+import { IReduxState } from '../../../app/types';import {getLocalParticipant,getParticipantById,@@ -10,14 +9,18 @@ import {hasRaisedHand,isParticipantModerator} from '../../../base/participants/functions';-import { FakeParticipant, IParticipant } from '../../../base/participants/types';+import { FakeParticipant } from '../../../base/participants/types';import {isParticipantAudioMuted,isParticipantVideoMuted} from '../../../base/tracks/functions.native';import { showContextMenuDetails, showSharedVideoMenu } from '../../actions.native';import type { MediaState } from '../../constants';-import { getParticipantAudioMediaState, getParticipantVideoMediaState } from '../../functions';+import {+ getParticipantAudioMediaState,+ getParticipantVideoMediaState,+ participantMatchesSearch+} from '../../functions';import ParticipantItem from './ParticipantItem';@@ -59,9 +62,9 @@ interface IProps {_localVideoOwner: boolean;/**- * The participant ID.+ * Whether or not the participant name matches the search string.*/- _participantID: string;+ _matchesSearch: boolean;/*** True if the participant have raised hand.@@ -74,85 +77,55 @@ interface IProps {_videoMediaState: MediaState;/**- * The redux dispatch function.+ * The participant ID.*/- dispatch: IStore['dispatch'];+ participantID: string;/**- * The participant.+ * Name of the participant we search for.*/- participant?: IParticipant;+ searchString: string;}-/**- * Implements the MeetingParticipantItem component.- */-class MeetingParticipantItem extends PureComponent<IProps> {-- /**- * Creates new MeetingParticipantItem instance.- *- * @param {IProps} props - The props of the component.- */- constructor(props: IProps) {- super(props);-- this._onPress = this._onPress.bind(this);- }-- /**- * Handles MeetingParticipantItem press events.- *- * @returns {void}- */- _onPress() {- const {- _fakeParticipant,- _local,- _localVideoOwner,- _participantID,- dispatch- } = this.props;-+const MeetingParticipantItem = ({+ _audioMediaState,+ _disableModeratorIndicator,+ _displayName,+ _fakeParticipant,+ _isModerator,+ _local,+ _localVideoOwner,+ _matchesSearch,+ _raisedHand,+ _videoMediaState,+ participantID+}: IProps) => {+ const dispatch = useDispatch();+ const onPress = useCallback(() => {if (_fakeParticipant && _localVideoOwner) {- dispatch(showSharedVideoMenu(_participantID));+ dispatch(showSharedVideoMenu(participantID));} else if (!_fakeParticipant) {- dispatch(showContextMenuDetails(_participantID, _local));+ dispatch(showContextMenuDetails(participantID, _local));} // else no-op- }+ }, [ dispatch ]);- /**- * Implements React's {@link Component#render()}.- *- * @inheritdoc- * @returns {ReactElement}- */- override render() {- const {- _audioMediaState,- _disableModeratorIndicator,- _displayName,- _isModerator,- _local,- _participantID,- _raisedHand,- _videoMediaState- } = this.props;-- return (- <ParticipantItem- audioMediaState = { _audioMediaState }- disableModeratorIndicator = { _disableModeratorIndicator }- displayName = { _displayName }- isModerator = { _isModerator }- local = { _local }- onPress = { this._onPress }- participantID = { _participantID }- raisedHand = { _raisedHand }- videoMediaState = { _videoMediaState } />- );+ if (!_matchesSearch) {+ return null;}-}++ return (+ <ParticipantItem+ audioMediaState = { _audioMediaState }+ disableModeratorIndicator = { _disableModeratorIndicator }+ displayName = { _displayName }+ isModerator = { _isModerator }+ local = { _local }+ onPress = { onPress }+ participantID = { participantID }+ raisedHand = { _raisedHand }+ videoMediaState = { _videoMediaState } />+ );+};/*** Maps (parts of) the redux state to the associated props for this component.@@ -163,8 +136,9 @@ class MeetingParticipantItem extends PureComponent<IProps> {* @returns {IProps}*/function mapStateToProps(state: IReduxState, ownProps: any) {- const { participant } = ownProps;+ const { participantID, searchString } = ownProps;const { ownerId } = state['features/shared-video'];+ const participant = getParticipantById(state, participantID);const localParticipantId = getLocalParticipant(state)?.id;const _isAudioMuted = isParticipantAudioMuted(participant, state);const _isVideoMuted = isParticipantVideoMuted(participant, state);@@ -173,23 +147,24 @@ function mapStateToProps(state: IReduxState, ownProps: any) {const { disableModeratorIndicator } = state['features/base/config'];const raisedHand = hasRaisedHand(participant?.local? participant- : getParticipantById(state, participant?.id)+ : getParticipantById(state, participantID));+ const _matchesSearch = participantMatchesSearch(participant, searchString);return {_audioMediaState: audioMediaState,_disableModeratorIndicator: disableModeratorIndicator,- _displayName: getParticipantDisplayName(state, participant?.id),+ _displayName: getParticipantDisplayName(state, participantID),_fakeParticipant: participant?.fakeParticipant,_isAudioMuted,_isModerator: isParticipantModerator(participant),_local: Boolean(participant?.local),_localVideoOwner: Boolean(ownerId === localParticipantId),- _participantID: participant?.id,+ _matchesSearch,_raisedHand: raisedHand,_videoMediaState: videoMediaState};}--export default translate(connect(mapStateToProps)(MeetingParticipantItem));+// @ts-ignore+export default connect(mapStateToProps)(MeetingParticipantItem);diff --git a/react/features/participants-pane/components/native/MeetingParticipantList.tsx b/react/features/participants-pane/components/native/MeetingParticipantList.tsxindex 5e0037590b..cfed14171a 100644--- a/react/features/participants-pane/components/native/MeetingParticipantList.tsx+++ b/react/features/participants-pane/components/native/MeetingParticipantList.tsx@@ -1,16 +1,15 @@import React, { useCallback, useState } from 'react';import { useTranslation } from 'react-i18next';import { FlatList, Text, TextStyle, View } from 'react-native';-import { useDispatch, useSelector } from 'react-redux';+import { connect, useDispatch } from 'react-redux';import { IReduxState } from '../../../app/types';import Icon from '../../../base/icons/components/Icon';import { IconAddUser } from '../../../base/icons/svg';import {addPeopleFeatureControl,- getLocalParticipant,- getParticipantCountWithFake,- getRemoteParticipants,+ getParticipantById,+ isScreenShareParticipant,setShareDialogVisiblity} from '../../../base/participants/functions';import Button from '../../../base/ui/components/native/Button';@@ -23,57 +22,70 @@ import {import { doInvitePeople } from '../../../invite/actions.native';import { getInviteOthersControl } from '../../../share-room/functions';import { iAmVisitor } from '../../../visitors/functions';-import { participantMatchesSearch, shouldRenderInviteButton } from '../../functions';+import { getSortedParticipantIds, shouldRenderInviteButton } from '../../functions';import MeetingParticipantItem from './MeetingParticipantItem';import styles from './styles';+interface IProps {+ currentRoom?: {+ jid: string;+ name: string;+ };+ iconColor: string;+ isAddPeopleFeatureEnabled?: boolean | undefined;+ isShareDialogVisible: boolean;+ participantsCount?: number;+ showInviteButton?: boolean;+ sortedParticipantIds?: Array<string>;+ visitorsCount?: number | undefined;+}+++const MeetingParticipantList = ({+ currentRoom,+ iconColor,+ isAddPeopleFeatureEnabled,+ isShareDialogVisible,+ participantsCount,+ showInviteButton,+ sortedParticipantIds = [],+ visitorsCount+}: IProps): any => {+ const { t } = useTranslation();++ const [ searchString, setSearchString ] = useState('');-const MeetingParticipantList = () => {- const currentRoomId = useSelector(getCurrentRoomId);- const currentRoom = useSelector(getBreakoutRooms)[currentRoomId];const dispatch = useDispatch();- const inviteOthersControl = useSelector(getInviteOthersControl);- const isAddPeopleFeatureEnabled = useSelector(addPeopleFeatureControl);- const keyExtractor- = useCallback((e: undefined, i: number) => i.toString(), []);- const localParticipant = useSelector(getLocalParticipant);- const _iAmVisitor = useSelector(iAmVisitor);++ const keyExtractor = useCallback((e: undefined, i: number) => i.toString(), []);const onInvite = useCallback(() => {setShareDialogVisiblity(isAddPeopleFeatureEnabled, dispatch);dispatch(doInvitePeople());}, [ dispatch ]);- const [ searchString, setSearchString ] = useState('');const onSearchStringChange = useCallback((text: string) =>setSearchString(text), []);- const participantsCount = useSelector(getParticipantCountWithFake);- const remoteParticipants = useSelector(getRemoteParticipants);- const renderParticipant = ({ item/* , index, separators */ }: any) => {- const participant = item === localParticipant?.id- ? localParticipant : remoteParticipants.get(item);-- if (participantMatchesSearch(participant, searchString)) {- return (- <MeetingParticipantItem- key = { item }- participant = { participant } />- );- }- return null;- };- const showInviteButton = useSelector(shouldRenderInviteButton);- const sortedRemoteParticipants = useSelector(- (state: IReduxState) => state['features/filmstrip'].remoteParticipants);- const { t } = useTranslation();const title = currentRoom?.name? `${currentRoom.name} (${participantsCount})`: t('participantsPane.headings.participantsList',{ count: participantsCount });- const { color, shareDialogVisible } = inviteOthersControl;+ const visitorsLabelText = visitorsCount && visitorsCount > 0+ ? t('participantsPane.headings.visitors', { count: visitorsCount })+ : undefined;++ const renderParticipant = ({ item }: any) => (+ <MeetingParticipantItem+ key = { item }+ participantID = { item }+ searchString = { searchString } />+ );return (<View style = { styles.meetingListContainer }>+ <Text style = { styles.visitorsLabel as TextStyle }>+ { visitorsLabelText }+ </Text><Textstyle = { styles.meetingListDescription as TextStyle }>{ title }@@ -82,12 +94,12 @@ const MeetingParticipantList = () => {showInviteButton&& <ButtonaccessibilityLabel = 'participantsPane.actions.invite'- disabled = { shareDialogVisible }+ disabled = { isShareDialogVisible }// eslint-disable-next-line react/jsx-no-bind, no-confusing-arrowicon = { () => (<Icon- color = { color }+ color = { iconColor }size = { 20 }src = { IconAddUser } />) }@@ -105,10 +117,7 @@ const MeetingParticipantList = () => {placeholder = { t('participantsPane.search') }value = { searchString } /><FlatList- data = { _iAmVisitor- ? [ ...sortedRemoteParticipants ]- : [ localParticipant?.id, ...sortedRemoteParticipants ] as Array<any>- }+ data = { sortedParticipantIds as Array<any> }keyExtractor = { keyExtractor }/* eslint-disable react/jsx-no-bind */@@ -118,4 +127,48 @@ const MeetingParticipantList = () => {);};-export default MeetingParticipantList;+/**+ * Maps (parts of) the redux state to the associated props for this component.+ *+ * @param {Object} state - The Redux state.+ * @private+ * @returns {IProps}+ */+function _mapStateToProps(state: IReduxState) {+ let sortedParticipantIds: any = getSortedParticipantIds(state);++ const _iAmVisitor = iAmVisitor(state);++ sortedParticipantIds = sortedParticipantIds.filter((id: any) => {+ const participant = getParticipantById(state, id);++ if (_iAmVisitor && participant?.local) {+ return false;+ }++ return !isScreenShareParticipant(participant);+ });++ const currentRoomId = getCurrentRoomId(state);+ const currentRoom = getBreakoutRooms(state)[currentRoomId];+ const inviteOthersControl = getInviteOthersControl(state);+ const { color, shareDialogVisible } = inviteOthersControl;+ const isAddPeopleFeatureEnabled = addPeopleFeatureControl(state);+ const participantsCount = sortedParticipantIds.length;+ const showInviteButton = shouldRenderInviteButton(state);+ const visitorsCount = state['features/visitors']?.count || 0;++ return {+ currentRoom,+ iconColor: color,+ inviteOthersControl,+ isAddPeopleFeatureEnabled,+ isShareDialogVisible: shareDialogVisible,+ participantsCount,+ showInviteButton,+ sortedParticipantIds,+ visitorsCount+ };+}++export default connect(_mapStateToProps)(MeetingParticipantList);diff --git a/react/features/participants-pane/components/native/ParticipantsPane.tsx b/react/features/participants-pane/components/native/ParticipantsPane.tsxindex cac00d7526..47fb682571 100644--- a/react/features/participants-pane/components/native/ParticipantsPane.tsx+++ b/react/features/participants-pane/components/native/ParticipantsPane.tsx@@ -12,11 +12,6 @@ import VisitorsList from './VisitorsList';import styles from './styles';-/**- * Participants pane.- *- * @returns {React$Element<any>}- */const ParticipantsPane = () => {const isLocalModerator = useSelector(isLocalParticipantModerator);const keyExtractordiff --git a/react/features/participants-pane/components/native/styles.ts b/react/features/participants-pane/components/native/styles.tsindex 0072e00c3f..438b4071cf 100644--- a/react/features/participants-pane/components/native/styles.ts+++ b/react/features/participants-pane/components/native/styles.ts@@ -9,7 +9,7 @@ const participantListDescription = {fontSize: 15,fontWeight: 'bold',marginLeft: BaseTheme.spacing[2],- paddingVertical: BaseTheme.spacing[2],+ marginVertical: BaseTheme.spacing[2],position: 'relative',width: '70%'};@@ -275,13 +275,11 @@ export default {},inputContainer: {- marginLeft: BaseTheme.spacing[3],- marginRight: BaseTheme.spacing[3],- marginBottom: BaseTheme.spacing[4]+ marginHorizontal: BaseTheme.spacing[3],+ marginBottom: BaseTheme.spacing[3]},centerInput: {- paddingRight: BaseTheme.spacing[3],textAlign: 'center'},diff --git a/react/features/participants-pane/components/web/MeetingParticipants.tsx b/react/features/participants-pane/components/web/MeetingParticipants.tsxindex 21e32a3d5b..0fd727982e 100644--- a/react/features/participants-pane/components/web/MeetingParticipants.tsx+++ b/react/features/participants-pane/components/web/MeetingParticipants.tsx@@ -13,7 +13,7 @@ import { getBreakoutRooms, getCurrentRoomId, isInBreakoutRoom } from '../../../bimport { isButtonEnabled, showOverflowDrawer } from '../../../toolbox/functions.web';import { iAmVisitor } from '../../../visitors/functions';import { getSortedParticipantIds, isCurrentRoomRenamable, shouldRenderInviteButton } from '../../functions';-import { useParticipantDrawer } from '../../hooks';+import { useParticipantDrawer } from '../../hooks.web';import RenameButton from '../breakout-rooms/components/web/RenameButton';import { InviteButton } from './InviteButton';