From 1bc3f542f25ddb0ecbc5b7bad8bc8e64353f8729 Mon Sep 17 00:00:00 2001
From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com>
Date: Fri, 9 Sep 2022 11:49:06 -0300
Subject: [PATCH] Regression: Create private team and channel as default
(#4493)
* Regression: Create private team and channel as default
* minor tweak
---
.../RoomSettings/SwitchItemType.tsx | 18 ++++-----------
.../CreateChannelView/RoomSettings/index.tsx | 22 +++++++++++++++++--
app/views/CreateChannelView/index.tsx | 13 ++++++++---
3 files changed, 34 insertions(+), 19 deletions(-)
diff --git a/app/views/CreateChannelView/RoomSettings/SwitchItemType.tsx b/app/views/CreateChannelView/RoomSettings/SwitchItemType.tsx
index 6299dec97..269fce66a 100644
--- a/app/views/CreateChannelView/RoomSettings/SwitchItemType.tsx
+++ b/app/views/CreateChannelView/RoomSettings/SwitchItemType.tsx
@@ -1,21 +1,18 @@
import React from 'react';
-import { usePermissions } from '../../../lib/hooks';
import { SwitchItem } from './SwitchItem';
export const SwitchItemType = ({
isTeam,
type,
- onValueChangeType
+ onValueChangeType,
+ isDisabled
}: {
isTeam: boolean;
type: boolean;
onValueChangeType: (value: boolean) => void;
+ isDisabled: boolean;
}) => {
- const [createChannelPermission, createPrivateChannelPermission] = usePermissions(['create-c', 'create-p']);
-
- const isDisabled = [createChannelPermission, createPrivateChannelPermission].filter(r => r === true).length <= 1;
-
let hint = '';
if (isTeam && type) {
hint = 'Team_hint_private';
@@ -31,13 +28,6 @@ export const SwitchItemType = ({
}
return (
-
+
);
};
diff --git a/app/views/CreateChannelView/RoomSettings/index.tsx b/app/views/CreateChannelView/RoomSettings/index.tsx
index 5d27ca1e0..f12b9c896 100644
--- a/app/views/CreateChannelView/RoomSettings/index.tsx
+++ b/app/views/CreateChannelView/RoomSettings/index.tsx
@@ -9,7 +9,17 @@ import { SwitchItemReadOnly } from './SwitchItemReadOnly';
import { SwitchItemEncrypted } from './SwitchItemEncrypted';
import { IFormData } from '..';
-export const RoomSettings = ({ isTeam, setValue }: { isTeam: boolean; setValue: UseFormSetValue }) => {
+export const RoomSettings = ({
+ isTeam,
+ setValue,
+ createChannelPermission,
+ createPrivateChannelPermission
+}: {
+ isTeam: boolean;
+ setValue: UseFormSetValue;
+ createChannelPermission: boolean;
+ createPrivateChannelPermission: boolean;
+}) => {
const [type, setType] = useState(true);
const [readOnly, setReadOnly] = useState(false);
const [encrypted, setEncrypted] = useState(false);
@@ -50,9 +60,17 @@ export const RoomSettings = ({ isTeam, setValue }: { isTeam: boolean; setValue:
setReadOnly(value ? true : readOnly);
setValue('readOnly', value ? true : readOnly);
};
+
+ const isDisabled = [createChannelPermission, createPrivateChannelPermission].filter(r => r === true).length <= 1;
+
return (
<>
-
+
{
+ const [createChannelPermission, createPrivateChannelPermission] = usePermissions(['create-c', 'create-p']);
+
const {
control,
handleSubmit,
formState: { isDirty },
setValue
} = useForm({
- defaultValues: { channelName: '', broadcast: false, encrypted: false, readOnly: false, type: false }
+ defaultValues: { channelName: '', broadcast: false, encrypted: false, readOnly: false, type: createPrivateChannelPermission }
});
const navigation = useNavigation>();
@@ -148,7 +150,12 @@ const CreateChannelView = () => {
name={'channelName'}
control={control}
/>
-
+
{users.length > 0 ? (
<>