diff --git a/src/crypto/RoomList.js b/src/crypto/RoomList.js index 5bb437fb7..eb5b469c6 100644 --- a/src/crypto/RoomList.js +++ b/src/crypto/RoomList.js @@ -71,6 +71,9 @@ export default class RoomList { } async setRoomEncryption(roomId, roomInfo) { + // important that this happens before calling into the store + // as it prevents the Crypto::setRoomEncryption for calling + // this twice for consecutive m.room.encryption events this._roomEncryption[roomId] = roomInfo; await this._cryptoStore.doTxn( 'readwrite', [IndexedDBCryptoStore.STORE_ROOMS], (txn) => { diff --git a/src/sync.js b/src/sync.js index 4aa2d2482..d8dffe6b3 100644 --- a/src/sync.js +++ b/src/sync.js @@ -1085,15 +1085,16 @@ SyncApi.prototype._processSyncResponse = async function( self._processEventsForNotifs(room, timelineEvents); - async function processRoomEvent(e) { + function processRoomEvent(e) { client.emit("event", e); if (e.isState() && e.getType() == "m.room.encryption" && self.opts.crypto) { - await self.opts.crypto.onCryptoEvent(e); + self.opts.crypto.onCryptoEvent(e); } } - await Promise.mapSeries(stateEvents, processRoomEvent); - await Promise.mapSeries(timelineEvents, processRoomEvent); + stateEvents.forEach(processRoomEvent); + timelineEvents.forEach(processRoomEvent); + ephemeralEvents.forEach(function(e) { client.emit("event", e); });