Fix get rooms info (#12492)
* Include local participant; filter out hidden participants for getRoomsInfo * Review fixes: include ts changes and types Co-authored-by: Bogdan Duduman <bogdan.duduman@8x8.com>
This commit is contained in:
parent
7a3b8d6ac4
commit
31766c891b
|
@ -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.
|
||||
|
|
|
@ -51,5 +51,9 @@ export interface ILocalParticipant extends IParticipant {
|
|||
}
|
||||
|
||||
export interface IJitsiParticipant {
|
||||
getDisplayName: () => string;
|
||||
getId: () => string;
|
||||
getJid: () => string;
|
||||
getRole: () => string;
|
||||
isHidden: () => boolean;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
participants: conferenceParticipants?.length > 0
|
||||
? [
|
||||
localParticipantInfo,
|
||||
...conferenceParticipants.map((participantItem: IJitsiParticipant) => {
|
||||
const storeParticipant = getParticipantById(stateful, participantItem.getId());
|
||||
|
||||
return {
|
||||
jid: participantItem._jid,
|
||||
role: participantItem._role,
|
||||
displayName: participantItem._displayName,
|
||||
avatarUrl: storeParticipant?.loadableAvatarUrl,
|
||||
id: participantItem._id
|
||||
};
|
||||
}) : []
|
||||
} ]
|
||||
};
|
||||
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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue