Fix bug when creating room
authorAjay Bura <ajbura@gmail.com>
Sun, 27 Feb 2022 05:20:27 +0000 (10:50 +0530)
committerAjay Bura <ajbura@gmail.com>
Sun, 27 Feb 2022 05:20:27 +0000 (10:50 +0530)
Signed-off-by: Ajay Bura <ajbura@gmail.com>
src/app/organisms/create-room/CreateRoom.jsx
src/client/action/room.js

index 20e7609fa93429c0076ec094e6c87a8dfcd2703d..03dba8ec8121b507949b0fa83ce01ecd4497d5e5 100644 (file)
@@ -51,13 +51,10 @@ function CreateRoomContent({ isSpace, parentId, onRequestClose }) {
   useEffect(() => {
     const { roomList } = initMatrix;
     const onCreated = (roomId) => {
-      setJoinRule(false);
-      setIsEncrypted(true);
-      setIsValidAddress(null);
       setIsCreatingRoom(false);
       setCreatingError(null);
+      setIsValidAddress(null);
       setAddressValue(undefined);
-      setRoleIndex(0);
 
       if (!mx.getRoom(roomId)?.isSpaceRoom()) {
         selectRoom(roomId);
index c6145bed3a29f184f6e97aaecb0658ce7fb10e54..10927511f9aff4d477a8e4b3bfe16b4289b5e022 100644 (file)
@@ -224,6 +224,17 @@ async function createRoom(opts) {
     });
   }
   if (parentId && joinRule === 'restricted') {
+    try {
+      const caps = await mx.getCapabilities();
+      options.room_version = caps
+        ?.['m.room_versions']
+        ?.['org.matrix.msc3244.room_capabilities']
+        ?.restricted
+        ?.preferred
+        || undefined;
+    } catch {
+      console.error('Can\'t find room version for restricted.');
+    }
     options.initial_state.push({
       type: 'm.room.join_rules',
       content: {