Tweak edge case behaviour

This commit is contained in:
Michael Telatynski 2021-09-09 10:54:31 +01:00
parent fa60b24a9f
commit 2eb64de508

View File

@ -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;