Show voice room participants when not connected (#8136)
* Add utility for getting connected voice participants * Allow voice room members to send connected device state * Update connected devices when connecting/disconnecting voice * Show voice room participants in room tile when not connected * Update voice room tests * Add null types and guards
This commit is contained in:
parent
0a16989d26
commit
8baf06c3ff
10 changed files with 378 additions and 143 deletions
|
@ -15,18 +15,33 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import { CallType } from "matrix-js-sdk/src/webrtc/call";
|
||||
import { RoomState } from "matrix-js-sdk/src/models/room-state";
|
||||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||
|
||||
import WidgetStore, { IApp } from "../stores/WidgetStore";
|
||||
import { WidgetType } from "../widgets/WidgetType";
|
||||
import WidgetUtils from "./WidgetUtils";
|
||||
|
||||
export const VOICE_CHANNEL_ID = "io.element.voice";
|
||||
export const VOICE_CHANNEL = "io.element.voice";
|
||||
export const VOICE_CHANNEL_MEMBER = "io.element.voice.member";
|
||||
|
||||
export interface IVoiceChannelMemberContent {
|
||||
// Connected device IDs
|
||||
devices: string[];
|
||||
}
|
||||
|
||||
export const getVoiceChannel = (roomId: string): IApp => {
|
||||
const apps = WidgetStore.instance.getApps(roomId);
|
||||
return apps.find(app => WidgetType.JITSI.matches(app.type) && app.id === VOICE_CHANNEL_ID);
|
||||
return apps.find(app => WidgetType.JITSI.matches(app.type) && app.id === VOICE_CHANNEL);
|
||||
};
|
||||
|
||||
export const addVoiceChannel = async (roomId: string, roomName: string) => {
|
||||
await WidgetUtils.addJitsiWidget(roomId, CallType.Voice, "Voice channel", VOICE_CHANNEL_ID, roomName);
|
||||
await WidgetUtils.addJitsiWidget(roomId, CallType.Voice, "Voice channel", VOICE_CHANNEL, roomName);
|
||||
};
|
||||
|
||||
export const getConnectedMembers = (state: RoomState): RoomMember[] =>
|
||||
state.getStateEvents(VOICE_CHANNEL_MEMBER)
|
||||
// Must have a device connected and still be joined to the room
|
||||
.filter(e => e.getContent<IVoiceChannelMemberContent>().devices?.length)
|
||||
.map(e => state.getMember(e.getStateKey()))
|
||||
.filter(member => member.membership === "join");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue