1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

don't block on setting up room crypto

this will load members in case of LL and could take quite some time
The two async actions performed by onCryptoEvent is saving the crypto config
to the roomlist store and fetching the room members to track.
Both are guarded against double calls so not awaiting this should be fine.
This commit is contained in:
Bruno Windels
2018-08-22 14:45:36 +02:00
parent 52fad6aec2
commit 71444b638b
2 changed files with 8 additions and 4 deletions

View File

@@ -71,6 +71,9 @@ export default class RoomList {
} }
async setRoomEncryption(roomId, roomInfo) { 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; this._roomEncryption[roomId] = roomInfo;
await this._cryptoStore.doTxn( await this._cryptoStore.doTxn(
'readwrite', [IndexedDBCryptoStore.STORE_ROOMS], (txn) => { 'readwrite', [IndexedDBCryptoStore.STORE_ROOMS], (txn) => {

View File

@@ -1085,15 +1085,16 @@ SyncApi.prototype._processSyncResponse = async function(
self._processEventsForNotifs(room, timelineEvents); self._processEventsForNotifs(room, timelineEvents);
async function processRoomEvent(e) { function processRoomEvent(e) {
client.emit("event", e); client.emit("event", e);
if (e.isState() && e.getType() == "m.room.encryption" && self.opts.crypto) { 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); stateEvents.forEach(processRoomEvent);
await Promise.mapSeries(timelineEvents, processRoomEvent); timelineEvents.forEach(processRoomEvent);
ephemeralEvents.forEach(function(e) { ephemeralEvents.forEach(function(e) {
client.emit("event", e); client.emit("event", e);
}); });