Ensure we have crypto before accessing it in Room model

If crypto startup has failed, we shouldn't try to access any of its methods.
This fixes a variant of this in the `Room` model.
This commit is contained in:
J. Ryan Stinnett
2019-04-03 16:45:41 +01:00
parent 98624871bd
commit 6ba7e85e24
2 changed files with 4 additions and 1 deletions
+3
View File
@@ -1318,6 +1318,9 @@ describe("Room", function() {
// events should already be MatrixEvents
return function(event) {return event;};
},
isCryptoEnabled() {
return true;
},
isRoomEncrypted: function() {
return false;
},
+1 -1
View File
@@ -496,7 +496,7 @@ Room.prototype.loadMembersIfNeeded = function() {
const inMemoryUpdate = this._loadMembers().then((result) => {
this.currentState.setOutOfBandMembers(result.memberEvents);
// now the members are loaded, start to track the e2e devices if needed
if (this._client.isRoomEncrypted(this.roomId)) {
if (this._client.isCryptoEnabled() && this._client.isRoomEncrypted(this.roomId)) {
this._client._crypto.trackRoomDevices(this.roomId);
}
return result.fromServer;