From 982398b32fcc240f66e7f98d1a424a4249b50f54 Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Fri, 15 Jul 2022 13:05:06 -0400 Subject: [PATCH] Remove unnecessary complexity from createRoom With fae4c504c9ee0d060b1cc56f979befde755c921e, the changes from b4a56f6dd74438367f989d79610674380575473d are no longer necessary. --- src/matrix-utils.ts | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/matrix-utils.ts b/src/matrix-utils.ts index e7bf120..9b6a005 100644 --- a/src/matrix-utils.ts +++ b/src/matrix-utils.ts @@ -8,7 +8,6 @@ import { MemoryCryptoStore } from "matrix-js-sdk/src/crypto/store/memory-crypto- import { createClient, MatrixClient } from "matrix-js-sdk/src/matrix"; 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 { ISyncStateData, SyncState } from "matrix-js-sdk/src/sync"; import { logger } from "matrix-js-sdk/src/logger"; @@ -222,24 +221,7 @@ export async function createRoom( client: MatrixClient, name: string ): Promise { - let setExpectedRoomId: (roomId: string) => void; - const expectedRoomId = new Promise( - (resolve) => (setExpectedRoomId = resolve) - ); - - // There's no telling whether the new room will come down sync in the middle - // of the createRoom request, or after it, so start watching for it beforehand - const roomReceived = new Promise((resolve) => { - const onRoom = async (room: Room) => { - if (room.roomId === (await expectedRoomId)) { - resolve(); - client.off(ClientEvent.Room, onRoom); - } - }; - client.on(ClientEvent.Room, onRoom); - }); - - const createRoomResult = await client.createRoom({ + await client.createRoom({ visibility: Visibility.Private, preset: Preset.PublicChat, name, @@ -269,10 +251,6 @@ export async function createRoom( }, }); - // Wait for the room to come down sync before doing anything with it - setExpectedRoomId(createRoomResult.room_id); - await roomReceived; - return fullAliasFromRoomName(name, client); }