Skip to content

Commit

Permalink
[FIX] Create discussion request being sent with null value on encrypt…
Browse files Browse the repository at this point in the history
…ion param (#3033)
  • Loading branch information
diegolmello authored Apr 1, 2021
1 parent c5bf13c commit 4e0dc78
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions app/views/CreateDiscussionView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -145,17 +149,23 @@ 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 });
}

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
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 4e0dc78

Please sign in to comment.