Fix joining over federation from Space Home (via servers)
This commit is contained in:
parent
56dbd5f628
commit
d9f3e70b0b
1 changed files with 9 additions and 3 deletions
|
@ -258,20 +258,26 @@ const SpaceLanding = ({ space }) => {
|
||||||
</AccessibleButton>;
|
</AccessibleButton>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [loading, roomsMap, relations, numRooms] = useAsyncMemo(async () => {
|
const [loading, roomsMap, relations, viaMap, numRooms] = useAsyncMemo(async () => {
|
||||||
try {
|
try {
|
||||||
const data = await cli.getSpaceSummary(space.roomId, undefined, myMembership !== "join");
|
const data = await cli.getSpaceSummary(space.roomId, undefined, myMembership !== "join");
|
||||||
|
|
||||||
const parentChildRelations = new EnhancedMap<string, Map<string, ISpaceSummaryEvent>>();
|
const parentChildRelations = new EnhancedMap<string, Map<string, ISpaceSummaryEvent>>();
|
||||||
|
const viaMap = new EnhancedMap<string, Set<string>>();
|
||||||
data.events.map((ev: ISpaceSummaryEvent) => {
|
data.events.map((ev: ISpaceSummaryEvent) => {
|
||||||
if (ev.type === EventType.SpaceChild) {
|
if (ev.type === EventType.SpaceChild) {
|
||||||
parentChildRelations.getOrCreate(ev.room_id, new Map()).set(ev.state_key, ev);
|
parentChildRelations.getOrCreate(ev.room_id, new Map()).set(ev.state_key, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(ev.content["via"])) {
|
||||||
|
const set = viaMap.getOrCreate(ev.state_key, new Set());
|
||||||
|
ev.content["via"].forEach(via => set.add(via));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const roomsMap = new Map<string, ISpaceSummaryRoom>(data.rooms.map(r => [r.room_id, r]));
|
const roomsMap = new Map<string, ISpaceSummaryRoom>(data.rooms.map(r => [r.room_id, r]));
|
||||||
const numRooms = data.rooms.filter(r => r.room_type !== RoomType.Space).length;
|
const numRooms = data.rooms.filter(r => r.room_type !== RoomType.Space).length;
|
||||||
return [false, roomsMap, parentChildRelations, numRooms];
|
return [false, roomsMap, parentChildRelations, viaMap, numRooms];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e); // TODO
|
console.error(e); // TODO
|
||||||
}
|
}
|
||||||
|
@ -292,7 +298,7 @@ const SpaceLanding = ({ space }) => {
|
||||||
relations={relations}
|
relations={relations}
|
||||||
parents={new Set()}
|
parents={new Set()}
|
||||||
onViewRoomClick={(roomId, autoJoin) => {
|
onViewRoomClick={(roomId, autoJoin) => {
|
||||||
showRoom(roomsMap.get(roomId), [], autoJoin);
|
showRoom(roomsMap.get(roomId), Array.from(viaMap.get(roomId) || []), autoJoin);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</AutoHideScrollbar>;
|
</AutoHideScrollbar>;
|
||||||
|
|
Loading…
Reference in a new issue