From 2eb64de508d48a2d48c9d5ef214a16b0d77b1f08 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 9 Sep 2021 10:54:31 +0100 Subject: [PATCH] Tweak edge case behaviour --- .../views/settings/JoinRuleSettings.tsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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;