[FIX] Create discussion request being sent with null value on encryption param (#3033)

This commit is contained in:
Diego Mello 2021-04-01 09:24:28 -03:00 committed by GitHub
parent c5bf13c22d
commit 4e0dc784c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 7 deletions

View File

@ -116,10 +116,14 @@ class CreateChannelView extends React.Component {
} = this.state; } = this.state;
const { create } = this.props; const { create } = this.props;
// create discussion const params = {
create({ prid: prid || rid, pmid, t_name, reply, users
prid: prid || rid, pmid, t_name, reply, users, encrypted };
}); if (this.isEncryptionEnabled) {
params.encrypted = encrypted ?? false;
}
create(params);
}; };
valid = () => { valid = () => {
@ -145,6 +149,12 @@ class CreateChannelView extends React.Component {
this.setState({ users: value }); this.setState({ users: value });
} }
get isEncryptionEnabled() {
const { channel } = this.state;
const { encryptionEnabled } = this.props;
return encryptionEnabled && E2E_ROOM_TYPES[channel?.t];
}
onEncryptedChange = (value) => { onEncryptedChange = (value) => {
logEvent(events.CD_TOGGLE_ENCRY); logEvent(events.CD_TOGGLE_ENCRY);
this.setState({ encrypted: value }); this.setState({ encrypted: value });
@ -152,10 +162,10 @@ class CreateChannelView extends React.Component {
render() { render() {
const { const {
name, users, encrypted, channel name, users, encrypted
} = this.state; } = this.state;
const { const {
server, user, loading, blockUnauthenticatedAccess, theme, serverVersion, encryptionEnabled server, user, loading, blockUnauthenticatedAccess, theme, serverVersion
} = this.props; } = this.props;
return ( return (
<KeyboardView <KeyboardView
@ -196,7 +206,7 @@ class CreateChannelView extends React.Component {
serverVersion={serverVersion} serverVersion={serverVersion}
theme={theme} theme={theme}
/> />
{encryptionEnabled && E2E_ROOM_TYPES[channel?.t] {this.isEncryptionEnabled
? ( ? (
<> <>
<Text style={[styles.label, { color: themes[theme].titleText }]}>{I18n.t('Encrypted')}</Text> <Text style={[styles.label, { color: themes[theme].titleText }]}>{I18n.t('Encrypted')}</Text>