Consolidate all group call creation into useLoadGroupCall

This enables us to automatically create a group call in rooms that
exist, but contain no calls.
This commit is contained in:
Robin Townsend
2022-07-15 12:58:53 -04:00
parent b4a56f6dd7
commit fae4c504c9
4 changed files with 124 additions and 130 deletions

View File

@@ -10,10 +10,6 @@ import { ICreateClientOpts } from "matrix-js-sdk/src/matrix";
import { ClientEvent } from "matrix-js-sdk/src/client";
import { Room } from "matrix-js-sdk/src/models/room";
import { Visibility, Preset } from "matrix-js-sdk/src/@types/partials";
import {
GroupCallIntent,
GroupCallType,
} from "matrix-js-sdk/src/webrtc/groupCall";
import { ISyncStateData, SyncState } from "matrix-js-sdk/src/sync";
import { logger } from "matrix-js-sdk/src/logger";
@@ -224,8 +220,7 @@ export function isLocalRoomId(roomId: string): boolean {
export async function createRoom(
client: MatrixClient,
name: string,
isPtt = false
name: string
): Promise<string> {
let setExpectedRoomId: (roomId: string) => void;
const expectedRoomId = new Promise<string>(
@@ -278,15 +273,6 @@ export async function createRoom(
setExpectedRoomId(createRoomResult.room_id);
await roomReceived;
console.log(`Creating ${isPtt ? "PTT" : "video"} group call room`);
await client.createGroupCall(
createRoomResult.room_id,
isPtt ? GroupCallType.Voice : GroupCallType.Video,
isPtt,
GroupCallIntent.Prompt
);
return fullAliasFromRoomName(name, client);
}