Fix crash in room without create state event (#546)
authorAjay Bura <32841439+ajbura@users.noreply.github.com>
Thu, 12 May 2022 11:02:39 +0000 (16:32 +0530)
committerGitHub <noreply@github.com>
Thu, 12 May 2022 11:02:39 +0000 (16:32 +0530)
src/app/molecules/room-visibility/RoomVisibility.jsx

index 746a07a838b95aaeb9ccf9403f78127a581ec051..7a8528765d6ce860246c1ff7f4bbe8a96d6688b7 100644 (file)
@@ -70,7 +70,7 @@ function RoomVisibility({ roomId }) {
 
   const noSpaceParent = currentState.getStateEvents('m.space.parent').length === 0;
   const mCreate = currentState.getStateEvents('m.room.create')[0]?.getContent();
-  const roomVersion = Number(mCreate.room_version);
+  const roomVersion = Number(mCreate?.room_version ?? 0);
 
   const myPowerlevel = room.getMember(mx.getUserId())?.powerLevel || 0;
   const canChange = room.currentState.hasSufficientPowerLevelFor('state_default', myPowerlevel);