From 63076e77f567e3039df4af158308df3313c8f63b Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 12 Sep 2017 17:09:01 +0100 Subject: [PATCH] Only re-emit events from Event objects if needed The only event and Event emits is 'Event.decrypted', so don't bother to add listeners if the event isn't encrypted. --- src/client.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client.js b/src/client.js index 3a309fab6..e201197e2 100644 --- a/src/client.js +++ b/src/client.js @@ -3274,10 +3274,10 @@ function _resolve(callback, defer, res) { function _PojoToMatrixEventMapper(client) { function mapper(plainOldJsObject) { const event = new MatrixEvent(plainOldJsObject); - reEmit(client, event, [ - "Event.decrypted", - ]); if (event.isEncrypted()) { + reEmit(client, event, [ + "Event.decrypted", + ]); event.attemptDecryption(client._crypto); } return event;