mirror of
https://github.com/vector-im/element-call.git
synced 2024-11-15 00:04:59 +08:00
Don' always try to join rooms
Look up the alias manually instead. As hopefully explained by the comment. We hope this may fix a bug where the room ID appeared instead of the room name.
This commit is contained in:
parent
6bc8ccf1ce
commit
0297008339
@ -61,20 +61,41 @@ export const useLoadGroupCall = (
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchOrCreateRoom = async (): Promise<Room> => {
|
const fetchOrCreateRoom = async (): Promise<Room> => {
|
||||||
// We lowercase the localpart when we create the room, so we must lowercase
|
let room: Room | null = null;
|
||||||
// it here too (we just do the whole alias). We can't do the same to room IDs
|
if (roomIdOrAlias[0] === "#") {
|
||||||
// though.
|
// We lowercase the localpart when we create the room, so we must lowercase
|
||||||
const sanitisedIdOrAlias =
|
// it here too (we just do the whole alias). We can't do the same to room IDs
|
||||||
roomIdOrAlias[0] === "#" ? roomIdOrAlias.toLowerCase() : roomIdOrAlias;
|
// though.
|
||||||
|
// Also, we explicitly look up the room alias here. We previously just tried to
|
||||||
|
// join anyway but the js-sdk recreates the room if you pass the alias for a
|
||||||
|
// room you're already joined to (which it probably ought not to).
|
||||||
|
const lookupResult = await client.getRoomIdForAlias(
|
||||||
|
roomIdOrAlias.toLowerCase()
|
||||||
|
);
|
||||||
|
logger.info(`${roomIdOrAlias} resolved to ${lookupResult.room_id}`);
|
||||||
|
room = client.getRoom(lookupResult.room_id);
|
||||||
|
if (!room) {
|
||||||
|
logger.info(`Room ${lookupResult.room_id} not found, joining.`);
|
||||||
|
room = await client.joinRoom(lookupResult.room_id, {
|
||||||
|
viaServers: lookupResult.servers,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
logger.info(
|
||||||
|
`Already in room ${lookupResult.room_id}, not rejoining.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// room IDs we just try to join by their ID, which will not work in the
|
||||||
|
// general case without providing some servers to join via. We could provide
|
||||||
|
// our own server, but in practice that is implicit.
|
||||||
|
room = await client.joinRoom(roomIdOrAlias);
|
||||||
|
}
|
||||||
|
|
||||||
const room = await client.joinRoom(sanitisedIdOrAlias, {
|
|
||||||
viaServers,
|
|
||||||
});
|
|
||||||
logger.info(
|
logger.info(
|
||||||
`Joined ${sanitisedIdOrAlias}, waiting room to be ready for group calls`
|
`Joined ${roomIdOrAlias}, waiting room to be ready for group calls`
|
||||||
);
|
);
|
||||||
await client.waitUntilRoomReadyForGroupCalls(room.roomId);
|
await client.waitUntilRoomReadyForGroupCalls(room.roomId);
|
||||||
logger.info(`${sanitisedIdOrAlias}, is ready for group calls`);
|
logger.info(`${roomIdOrAlias}, is ready for group calls`);
|
||||||
return room;
|
return room;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user