Ensure room is actually in space hierarchy when resolving its latest version
Relates to: vector-im/element-web#24329
This commit is contained in:
parent
a69b805156
commit
e0e149be3d
1 changed files with 12 additions and 3 deletions
|
@ -413,9 +413,18 @@ interface IHierarchyLevelProps {
|
||||||
onToggleClick?(parentId: string, childId: string): void;
|
onToggleClick?(parentId: string, childId: string): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const toLocalRoom = (cli: MatrixClient, room: IHierarchyRoom): IHierarchyRoom => {
|
const toLocalRoom = (cli: MatrixClient, room: IHierarchyRoom, hierarchy: RoomHierarchy): IHierarchyRoom => {
|
||||||
const history = cli.getRoomUpgradeHistory(room.room_id, true);
|
const history = cli.getRoomUpgradeHistory(room.room_id, true);
|
||||||
const cliRoom = history[history.length - 1];
|
|
||||||
|
// Pick latest room that is actually part of the hierarchy
|
||||||
|
let cliRoom = null;
|
||||||
|
for (let idx = history.length - 1; idx >= 0; --idx) {
|
||||||
|
if (hierarchy.roomMap[history[idx].roomId]) {
|
||||||
|
cliRoom = history[idx];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (cliRoom) {
|
if (cliRoom) {
|
||||||
return {
|
return {
|
||||||
...room,
|
...room,
|
||||||
|
@ -461,7 +470,7 @@ export const HierarchyLevel: React.FC<IHierarchyLevelProps> = ({
|
||||||
(result, ev: IHierarchyRelation) => {
|
(result, ev: IHierarchyRelation) => {
|
||||||
const room = hierarchy.roomMap.get(ev.state_key);
|
const room = hierarchy.roomMap.get(ev.state_key);
|
||||||
if (room && roomSet.has(room)) {
|
if (room && roomSet.has(room)) {
|
||||||
result[room.room_type === RoomType.Space ? 0 : 1].push(toLocalRoom(cli, room));
|
result[room.room_type === RoomType.Space ? 0 : 1].push(toLocalRoom(cli, room, hierarchy));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue