tidy up code

pull/21833/head
Michael Telatynski 2021-09-07 12:07:18 +01:00
parent c915288044
commit f4f4686270
1 changed files with 9 additions and 5 deletions

View File

@ -371,12 +371,16 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
return room?.currentState.getStateEvents(EventType.SpaceParent)
.map(ev => {
const content = ev.getContent();
if (!Array.isArray(content?.via)) return;
const parent = this.matrixClient.getRoom(ev.getStateKey());
if (canonicalOnly && !content?.canonical) return;
if (parent.currentState.maySendStateEvent(EventType.SpaceChild, userId)) {
return parent;
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
})
.filter(Boolean) || [];
}