diff --git a/src/stores/SpaceStore.ts b/src/stores/SpaceStore.ts index bc05ca738b..ea5ff56aea 100644 --- a/src/stores/SpaceStore.ts +++ b/src/stores/SpaceStore.ts @@ -315,7 +315,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient { // 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))