null-guard space store getParents relation lookup (#7029)

This commit is contained in:
Michael Telatynski 2021-10-25 14:55:08 +01:00 committed by GitHub
parent be0fa6da7b
commit 92df0a35a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -315,7 +315,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
// 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
const parent = this.matrixClient.getRoom(ev.getStateKey());
const relation = parent.currentState.getStateEvents(EventType.SpaceChild, roomId);
const relation = parent?.currentState.getStateEvents(EventType.SpaceChild, roomId);
if (!parent?.currentState.maySendStateEvent(EventType.SpaceChild, userId) ||
// also skip this relation if the parent had this child added but then since removed it
(relation && !Array.isArray(relation.getContent().via))