Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Fix get rooms info (#12492)

Hristo Terezov31766c891bce
diff --git a/react/features/base/conference/reducer.ts b/react/features/base/conference/reducer.ts
index 35621cb0cd..8cd2f61c04 100644
--- a/react/features/base/conference/reducer.ts
+++ b/react/features/base/conference/reducer.ts
@@ -52,6 +52,7 @@ export interface IJitsiConference {
getLocalTracks: Function;
getMeetingUniqueId: Function;
getParticipantById: Function;
+ getParticipants: Function;
grantOwner: Function;
isAVModerationSupported: Function;
isCallstatsEnabled: Function;
@@ -68,6 +69,7 @@ export interface IJitsiConference {
on: Function;
removeTrack: Function;
replaceTrack: Function;
+ room: IJitsiConferenceRoom;
sendCommand: Function;
sendCommandOnce: Function;
sendEndpointMessage: Function;
@@ -111,6 +113,11 @@ export interface IConferenceState {
subject?: string;
}
+export interface IJitsiConferenceRoom {
+ myroomjid: string;
+ roomjid: string;
+}
+
/**
* Listen for actions that contain the conference object, so that it can be
* stored for use by other action creators.
diff --git a/react/features/base/participants/types.ts b/react/features/base/participants/types.ts
index 3c9a670870..539bf91aca 100644
--- a/react/features/base/participants/types.ts
+++ b/react/features/base/participants/types.ts
@@ -51,5 +51,9 @@ export interface ILocalParticipant extends IParticipant {
}
export interface IJitsiParticipant {
+ getDisplayName: () => string;
getId: () => string;
+ getJid: () => string;
+ getRole: () => string;
+ isHidden: () => boolean;
}
diff --git a/react/features/breakout-rooms/functions.ts b/react/features/breakout-rooms/functions.ts
index 6e28b96509..0dd8865164 100644
--- a/react/features/breakout-rooms/functions.ts
+++ b/react/features/breakout-rooms/functions.ts
@@ -2,11 +2,18 @@ import _ from 'lodash';
import { IStateful } from '../base/app/types';
import { getCurrentConference } from '../base/conference/functions';
-import { getParticipantById, getParticipantCount, isLocalParticipantModerator } from '../base/participants/functions';
+import { IJitsiConference } from '../base/conference/reducer';
+import {
+ getLocalParticipant,
+ getParticipantById,
+ getParticipantCount,
+ isLocalParticipantModerator
+} from '../base/participants/functions';
+import { IJitsiParticipant } from '../base/participants/types';
import { toState } from '../base/redux/functions';
import { FEATURE_KEY } from './constants';
-import { IRoom, IRooms } from './types';
+import { IRoom, IRoomInfo, IRoomInfoParticipant, IRooms, IRoomsInfo } from './types';
/**
* Returns the rooms object for breakout rooms.
@@ -30,9 +37,16 @@ export const getMainRoom = (stateful: IStateful) => {
return _.find(rooms, room => Boolean(room.isMainRoom));
};
+/**
+ * Returns the rooms info.
+ *
+ * @param {IStateful} stateful - The redux store, the redux.
+
+* @returns {IRoomsInfo} The rooms info.
+ */
export const getRoomsInfo = (stateful: IStateful) => {
const breakoutRooms = getBreakoutRooms(stateful);
- const conference = getCurrentConference(stateful);
+ const conference: IJitsiConference = getCurrentConference(stateful);
const initialRoomsInfo = {
rooms: []
@@ -40,27 +54,45 @@ export const getRoomsInfo = (stateful: IStateful) => {
// only main roomn
if (!breakoutRooms || Object.keys(breakoutRooms).length === 0) {
+ // filter out hidden participants
+ const conferenceParticipants = conference?.getParticipants()
+ .filter((participant: IJitsiParticipant) => !participant.isHidden());
+
+ const localParticipant = getLocalParticipant(stateful);
+ let localParticipantInfo;
+
+ if (localParticipant) {
+ localParticipantInfo = {
+ role: localParticipant.role,
+ displayName: localParticipant.name,
+ avatarUrl: localParticipant.loadableAvatarUrl,
+ id: localParticipant.id
+ };
+ }
+
return {
...initialRoomsInfo,
rooms: [ {
isMainRoom: true,
id: conference?.room?.roomjid,
jid: conference?.room?.myroomjid,
- participants: conference?.participants && Object.keys(conference.participants).length
- ? Object.keys(conference.participants).map(participantId => {
- const participantItem = conference?.participants[participantId];
- const storeParticipant = getParticipantById(stateful, participantItem._id);
-
- return {
- jid: participantItem._jid,
- role: participantItem._role,
- displayName: participantItem._displayName,
- avatarUrl: storeParticipant?.loadableAvatarUrl,
- id: participantItem._id
- };
- }) : []
- } ]
- };
+ participants: conferenceParticipants?.length > 0
+ ? [
+ localParticipantInfo,
+ ...conferenceParticipants.map((participantItem: IJitsiParticipant) => {
+ const storeParticipant = getParticipantById(stateful, participantItem.getId());
+
+ return {
+ jid: participantItem.getJid(),
+ role: participantItem.getRole(),
+ displayName: participantItem.getDisplayName(),
+ avatarUrl: storeParticipant?.loadableAvatarUrl,
+ id: participantItem.getId()
+ } as IRoomInfoParticipant;
+ }) ]
+ : [ localParticipantInfo ]
+ } as IRoomInfo ]
+ } as IRoomsInfo;
}
return {
@@ -86,11 +118,11 @@ export const getRoomsInfo = (stateful: IStateful) => {
avatarUrl: storeParticipant?.loadableAvatarUrl,
id: storeParticipant ? storeParticipant.id
: participantLongId
- };
+ } as IRoomInfoParticipant;
}) : []
- };
+ } as IRoomInfo;
})
- };
+ } as IRoomsInfo;
};
/**
diff --git a/react/features/breakout-rooms/types.ts b/react/features/breakout-rooms/types.ts
index 8eedeb8e96..bb4a47f6e4 100644
--- a/react/features/breakout-rooms/types.ts
+++ b/react/features/breakout-rooms/types.ts
@@ -15,3 +15,22 @@ export interface IRoom {
export interface IRooms {
[jid: string]: IRoom;
}
+
+export interface IRoomInfo {
+ id: string;
+ isMainRoom: boolean;
+ jid: string;
+ participants: IRoomInfoParticipant[];
+}
+
+export interface IRoomsInfo {
+ rooms: IRoomInfo[];
+}
+
+export interface IRoomInfoParticipant {
+ avatarUrl: string;
+ displayName: string;
+ id: string;
+ jid: string;
+ role: string;
+}