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;
|
getLocalTracks: Function;
|
||||||
getMeetingUniqueId: Function;
|
getMeetingUniqueId: Function;
|
||||||
getParticipantById: Function;
|
getParticipantById: Function;
|
||||||
|
getParticipants: Function;
|
||||||
grantOwner: Function;
|
grantOwner: Function;
|
||||||
isAVModerationSupported: Function;
|
isAVModerationSupported: Function;
|
||||||
isCallstatsEnabled: Function;
|
isCallstatsEnabled: Function;
|
||||||
|
@ -68,6 +69,7 @@ export interface IJitsiConference {
|
||||||
on: Function;
|
on: Function;
|
||||||
removeTrack: Function;
|
removeTrack: Function;
|
||||||
replaceTrack: Function;
|
replaceTrack: Function;
|
||||||
|
room: IJitsiConferenceRoom;
|
||||||
sendCommand: Function;
|
sendCommand: Function;
|
||||||
sendCommandOnce: Function;
|
sendCommandOnce: Function;
|
||||||
sendEndpointMessage: Function;
|
sendEndpointMessage: Function;
|
||||||
|
@ -111,6 +113,11 @@ export interface IConferenceState {
|
||||||
subject?: string;
|
subject?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IJitsiConferenceRoom {
|
||||||
|
myroomjid: string;
|
||||||
|
roomjid: string;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listen for actions that contain the conference object, so that it can be
|
* Listen for actions that contain the conference object, so that it can be
|
||||||
* stored for use by other action creators.
|
* stored for use by other action creators.
|
||||||
|
|
|
@ -51,5 +51,9 @@ export interface ILocalParticipant extends IParticipant {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IJitsiParticipant {
|
export interface IJitsiParticipant {
|
||||||
|
getDisplayName: () => string;
|
||||||
getId: () => string;
|
getId: () => string;
|
||||||
|
getJid: () => string;
|
||||||
|
getRole: () => string;
|
||||||
|
isHidden: () => boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,18 @@ import _ from 'lodash';
|
||||||
|
|
||||||
import { IStateful } from '../base/app/types';
|
import { IStateful } from '../base/app/types';
|
||||||
import { getCurrentConference } from '../base/conference/functions';
|
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 { toState } from '../base/redux/functions';
|
||||||
|
|
||||||
import { FEATURE_KEY } from './constants';
|
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.
|
* Returns the rooms object for breakout rooms.
|
||||||
|
@ -30,9 +37,16 @@ export const getMainRoom = (stateful: IStateful) => {
|
||||||
return _.find(rooms, room => Boolean(room.isMainRoom));
|
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) => {
|
export const getRoomsInfo = (stateful: IStateful) => {
|
||||||
const breakoutRooms = getBreakoutRooms(stateful);
|
const breakoutRooms = getBreakoutRooms(stateful);
|
||||||
const conference = getCurrentConference(stateful);
|
const conference: IJitsiConference = getCurrentConference(stateful);
|
||||||
|
|
||||||
const initialRoomsInfo = {
|
const initialRoomsInfo = {
|
||||||
rooms: []
|
rooms: []
|
||||||
|
@ -40,27 +54,45 @@ export const getRoomsInfo = (stateful: IStateful) => {
|
||||||
|
|
||||||
// only main roomn
|
// only main roomn
|
||||||
if (!breakoutRooms || Object.keys(breakoutRooms).length === 0) {
|
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 {
|
return {
|
||||||
...initialRoomsInfo,
|
...initialRoomsInfo,
|
||||||
rooms: [ {
|
rooms: [ {
|
||||||
isMainRoom: true,
|
isMainRoom: true,
|
||||||
id: conference?.room?.roomjid,
|
id: conference?.room?.roomjid,
|
||||||
jid: conference?.room?.myroomjid,
|
jid: conference?.room?.myroomjid,
|
||||||
participants: conference?.participants && Object.keys(conference.participants).length
|
participants: conferenceParticipants?.length > 0
|
||||||
? Object.keys(conference.participants).map(participantId => {
|
? [
|
||||||
const participantItem = conference?.participants[participantId];
|
localParticipantInfo,
|
||||||
const storeParticipant = getParticipantById(stateful, participantItem._id);
|
...conferenceParticipants.map((participantItem: IJitsiParticipant) => {
|
||||||
|
const storeParticipant = getParticipantById(stateful, participantItem.getId());
|
||||||
|
|
||||||
return {
|
return {
|
||||||
jid: participantItem._jid,
|
jid: participantItem.getJid(),
|
||||||
role: participantItem._role,
|
role: participantItem.getRole(),
|
||||||
displayName: participantItem._displayName,
|
displayName: participantItem.getDisplayName(),
|
||||||
avatarUrl: storeParticipant?.loadableAvatarUrl,
|
avatarUrl: storeParticipant?.loadableAvatarUrl,
|
||||||
id: participantItem._id
|
id: participantItem.getId()
|
||||||
};
|
} as IRoomInfoParticipant;
|
||||||
}) : []
|
}) ]
|
||||||
} ]
|
: [ localParticipantInfo ]
|
||||||
};
|
} as IRoomInfo ]
|
||||||
|
} as IRoomsInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -86,11 +118,11 @@ export const getRoomsInfo = (stateful: IStateful) => {
|
||||||
avatarUrl: storeParticipant?.loadableAvatarUrl,
|
avatarUrl: storeParticipant?.loadableAvatarUrl,
|
||||||
id: storeParticipant ? storeParticipant.id
|
id: storeParticipant ? storeParticipant.id
|
||||||
: participantLongId
|
: participantLongId
|
||||||
};
|
} as IRoomInfoParticipant;
|
||||||
}) : []
|
}) : []
|
||||||
};
|
} as IRoomInfo;
|
||||||
})
|
})
|
||||||
};
|
} as IRoomsInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,3 +15,22 @@ export interface IRoom {
|
||||||
export interface IRooms {
|
export interface IRooms {
|
||||||
[jid: string]: IRoom;
|
[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