diff --git a/src/components/views/settings/JoinRuleSettings.tsx b/src/components/views/settings/JoinRuleSettings.tsx index 3cb4456643..1ff7eb83f6 100644 --- a/src/components/views/settings/JoinRuleSettings.tsx +++ b/src/components/views/settings/JoinRuleSettings.tsx @@ -121,14 +121,20 @@ const JoinRuleSettings = ({ room, promptUpgrade, onError, beforeChange }: IProps const onRestrictedRoomIdsChange = (newAllowRoomIds: string[]) => { if (!arrayHasDiff(restrictedAllowRoomIds || [], newAllowRoomIds)) return; - const newContent: IJoinRuleEventContent = { + if (!newAllowRoomIds.length) { + setContent({ + join_rule: JoinRule.Invite, + }); + return; + } + + setContent({ join_rule: JoinRule.Restricted, allow: newAllowRoomIds.map(roomId => ({ "type": RestrictedAllowType.RoomMembership, "room_id": roomId, })), - }; - setContent(newContent); + }); }; const onEditRestrictedClick = async () => { @@ -209,6 +215,11 @@ const JoinRuleSettings = ({ room, promptUpgrade, onError, beforeChange }: IProps }); return; } + + // when setting to 0 allowed rooms/spaces set to invite only instead as per the note + if (!restrictedAllowRoomIds.length) { + joinRule = JoinRule.Invite; + } } if (beforeJoinRule === joinRule && !restrictedAllowRoomIds) return;