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 ? ( <>