Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into t3chguy/fix/18088
This commit is contained in:
commit
911ca07da4
38 changed files with 1134 additions and 379 deletions
|
@ -257,7 +257,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
|||
"go to that room's Security & Privacy settings.") }</p>
|
||||
|
||||
{ /* Reuses classes from TabbedView for simplicity, non-interactive */ }
|
||||
<div style={{ width: "190px" }}>
|
||||
<div className="mx_TabbedView_tabsOnLeft" style={{ width: "190px", position: "relative" }}>
|
||||
<div className="mx_TabbedView_tabLabel">
|
||||
<span className="mx_TabbedView_maskedIcon mx_RoomSettingsDialog_settingsIcon" />
|
||||
<span className="mx_TabbedView_tabLabel_text">{ _t("General") }</span>
|
||||
|
@ -366,16 +366,22 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
|||
}
|
||||
|
||||
public getParents(roomId: string, canonicalOnly = false): Room[] {
|
||||
const userId = this.matrixClient?.getUserId();
|
||||
const room = this.matrixClient?.getRoom(roomId);
|
||||
return room?.currentState.getStateEvents(EventType.SpaceParent)
|
||||
.filter(ev => {
|
||||
.map(ev => {
|
||||
const content = ev.getContent();
|
||||
if (!content?.via?.length) return false;
|
||||
// TODO apply permissions check to verify that the parent mapping is valid
|
||||
if (canonicalOnly && !content?.canonical) return false;
|
||||
return true;
|
||||
if (Array.isArray(content?.via) && (!canonicalOnly || content?.canonical)) {
|
||||
const parent = this.matrixClient.getRoom(ev.getStateKey());
|
||||
// only respect the relationship if the sender has sufficient permissions in the parent to set
|
||||
// child relations, as per MSC1772.
|
||||
// https://github.com/matrix-org/matrix-doc/blob/main/proposals/1772-groups-as-rooms.md#relationship-between-rooms-and-spaces
|
||||
if (parent?.currentState.maySendStateEvent(EventType.SpaceChild, userId)) {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
// else implicit undefined which causes this element to be filtered out
|
||||
})
|
||||
.map(ev => this.matrixClient.getRoom(ev.getStateKey()))
|
||||
.filter(Boolean) || [];
|
||||
}
|
||||
|
||||
|
@ -530,6 +536,14 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
|||
});
|
||||
}
|
||||
|
||||
const hiddenChildren = new EnhancedMap<string, Set<string>>();
|
||||
visibleRooms.forEach(room => {
|
||||
if (room.getMyMembership() !== "join") return;
|
||||
this.getParents(room.roomId).forEach(parent => {
|
||||
hiddenChildren.getOrCreate(parent.roomId, new Set()).add(room.roomId);
|
||||
});
|
||||
});
|
||||
|
||||
this.rootSpaces.forEach(s => {
|
||||
// traverse each space tree in DFS to build up the supersets as you go up,
|
||||
// reusing results from like subtrees.
|
||||
|
@ -559,6 +573,9 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
|||
roomIds.add(roomId);
|
||||
});
|
||||
});
|
||||
hiddenChildren.get(spaceId)?.forEach(roomId => {
|
||||
roomIds.add(roomId);
|
||||
});
|
||||
this.spaceFilteredRooms.set(spaceId, roomIds);
|
||||
return roomIds;
|
||||
};
|
||||
|
@ -690,6 +707,12 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
|||
}
|
||||
this.emit(room.roomId);
|
||||
break;
|
||||
|
||||
case EventType.RoomPowerLevels:
|
||||
if (room.isSpaceRoom()) {
|
||||
this.onRoomsUpdate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ import { containsEmoji } from "../../effects/utils";
|
|||
import dis from "../../dispatcher/dispatcher";
|
||||
import { tryTransformPermalinkToLocalHref } from "../../utils/permalinks/Permalinks";
|
||||
import { IEvent, MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||
import { Room } from "matrix-js-sdk";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
|
||||
// TODO: Purge this from the universe
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue