Add room id routing

This commit is contained in:
Robert Long
2021-12-10 13:44:06 -08:00
parent 8c287ffcb0
commit c5728b2f66
5 changed files with 37 additions and 18 deletions

View File

@@ -519,10 +519,9 @@ export function useGroupCallRooms(client) {
const groupCall = client.getGroupCallForRoom(room.roomId);
return {
roomId: room.roomId,
roomId: room.getCanonicalAlias() || room.roomId,
roomName: room.name,
avatarUrl: null,
roomUrl: `/room/${room.getCanonicalAlias() || room.roomId}`,
room,
groupCall,
participants: [...groupCall.participants],
@@ -554,11 +553,10 @@ export function usePublicRooms(client, publicSpaceRoomId, maxRooms = 50) {
const filteredRooms = rooms
.filter((room) => room.room_type !== "m.space")
.map((room) => ({
roomId: room.room_id,
roomId: room.room_alias || room.room_id,
roomName: room.name,
avatarUrl: null,
room,
roomUrl: `/room/${room.room_id}`,
participants: [],
}));
@@ -571,3 +569,17 @@ export function usePublicRooms(client, publicSpaceRoomId, maxRooms = 50) {
return rooms;
}
export function getRoomUrl(roomId) {
if (roomId.startsWith("#")) {
const [localPart, host] = roomId.replace("#", "").split(":");
if (host !== window.location.host) {
return `${window.location.host}/rooms/${roomId}`;
} else {
return `${window.location.host}/${localPart}`;
}
} else {
return `${window.location.host}/rooms/${roomId}`;
}
}