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