You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-29 16:43:09 +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:
@@ -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) => {
|
||||||
|
|||||||
@@ -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);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user