disable encryption flag

This commit is contained in:
2022-04-21 08:30:24 -06:00
parent eae9c737d7
commit 758af0c29b
3 changed files with 20 additions and 6 deletions

View File

@@ -221,9 +221,14 @@ class ChatBox extends React.Component {
this.setState({ ready: false })
const client = await this.createClientWithAccount()
try {
await client.initCrypto()
} catch(err) {
if(this.props.enableEncryption == "yes"){
try {
await client.initCrypto()
} catch(err) {
return this.restartWithoutCrypto()
}
}else{
return this.restartWithoutCrypto()
}
@@ -257,7 +262,9 @@ class ChatBox extends React.Component {
isCryptoEnabled: false,
})
this.displayBotMessage({ body: RESTARTING_UNENCRYPTED_CHAT_MESSAGE })
if(this.props.enableEncryption == "yes"){
this.displayBotMessage({ body: RESTARTING_UNENCRYPTED_CHAT_MESSAGE })
}
let opts = {
baseUrl: this.props.matrixServerUrl,
@@ -277,7 +284,9 @@ class ChatBox extends React.Component {
client.setDisplayName(this.props.displayName)
this.setMatrixListeners(client)
await this.createRoom(client)
this.displayBotMessage({ body: UNENCRYPTION_NOTICE })
if(this.props.enableEncryption == "yes"){
this.displayBotMessage({ body: UNENCRYPTION_NOTICE })
}
} catch(err) {
console.log("error", err)
this.handleInitError(err)
@@ -767,6 +776,7 @@ ChatBox.propTypes = {
chatUnavailableMessage: PropTypes.string,
displayName: PropTypes.string,
waitMessage: PropTypes.string,
enableEncryption: PropTypes.string,
chatOfflineMessage: PropTypes.string,
isEncryptionDisabled: PropTypes.bool,
position: PropTypes.oneOf(['top left', 'top right', 'bottom left', 'bottom right']),