diff --git a/src/components/structures/FilePanel.js b/src/components/structures/FilePanel.js index ff30c25073..bb7c1f9642 100644 --- a/src/components/structures/FilePanel.js +++ b/src/components/structures/FilePanel.js @@ -51,7 +51,7 @@ class FilePanel extends React.Component { if (toStartOfTimeline || !data || !data.liveEvent || ev.isRedacted()) return; const client = MatrixClientPeg.get(); - client.decryptEvent(ev); + client.decryptEventIfNeeded(ev); if (ev.isBeingDecrypted()) { this.decryptingEvents.add(ev.getId()); diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index 4918a4a3b4..af20c31cb2 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -1149,10 +1149,8 @@ class TimelinePanel extends React.Component { arrayFastClone(events) .reverse() .forEach(event => { - if (event.shouldAttemptDecryption()) { - const client = MatrixClientPeg.get(); - client.decryptEvent(event); - } + const client = MatrixClientPeg.get(); + client.decryptEventIfNeeded(event); }); const firstVisibleEventIndex = this._checkForPreJoinUISI(events); diff --git a/src/components/views/messages/MessageActionBar.js b/src/components/views/messages/MessageActionBar.js index 21b7cd64c9..37737519ce 100644 --- a/src/components/views/messages/MessageActionBar.js +++ b/src/components/views/messages/MessageActionBar.js @@ -124,10 +124,8 @@ export default class MessageActionBar extends React.PureComponent { this.props.mxEvent.on("Event.status", this.onSent); } - if (this.props.mxEvent.shouldAttemptDecryption()) { - const client = MatrixClientPeg.get(); - client.decryptEvent(this.props.mxEvent); - } + const client = MatrixClientPeg.get(); + client.decryptEventIfNeeded(this.props.mxEvent); if (this.props.mxEvent.isBeingDecrypted()) { this.props.mxEvent.once("Event.decrypted", this.onDecrypted); diff --git a/src/components/views/messages/ViewSourceEvent.js b/src/components/views/messages/ViewSourceEvent.js index 9e30261fd6..2ec567c5ad 100644 --- a/src/components/views/messages/ViewSourceEvent.js +++ b/src/components/views/messages/ViewSourceEvent.js @@ -39,9 +39,7 @@ export default class ViewSourceEvent extends React.PureComponent { const {mxEvent} = this.props; const client = MatrixClientPeg.get(); - if (mxEvent.shouldAttemptDecryption()) { - client.decryptEvent(mxEvent); - } + client.decryptEventIfNeeded(mxEvent); if (mxEvent.isBeingDecrypted()) { mxEvent.once("Event.decrypted", () => this.forceUpdate()); diff --git a/src/indexing/EventIndex.js b/src/indexing/EventIndex.js index 4d207d9f49..ed4418140b 100644 --- a/src/indexing/EventIndex.js +++ b/src/indexing/EventIndex.js @@ -189,7 +189,7 @@ export default class EventIndex extends EventEmitter { return; } - await client.decryptEvent(ev); + await client.decryptEventIfNeeded(ev); await this.addLiveEventToIndex(ev); } @@ -517,7 +517,7 @@ export default class EventIndex extends EventEmitter { const decryptionPromises = matrixEvents .filter(event => event.isEncrypted()) .map(event => { - return client.decryptEvent(event, { + return client.decryptEventIfNeeded(event, { isRetry: true, emit: false, });