Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Lazy loading: fix end-to-end encryption rooms #2113

Merged
merged 3 commits into from
Aug 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/VectorConferenceHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ ConferenceCall.prototype._getConferenceUserRoom = function() {
preset: "private_chat",
invite: [this.confUserId]
}).then(function(res) {
return new Room(res.room_id, client.getUserId());
return new Room(res.room_id, null, client.getUserId());
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/structures/RoomView.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ module.exports = React.createClass({

// lazy load members if enabled
if (SettingsStore.isFeatureEnabled('feature_lazyloading')) {
MatrixClientPeg.get().loadRoomMembersIfNeeded(room.roomId).catch((err) => {
room.loadMembersIfNeeded().catch((err) => {
const errorMessage = `Fetching room members for ${this.roomId} failed.` +
" Room members will appear incomplete.";
console.error(errorMessage);
Expand Down
29 changes: 14 additions & 15 deletions src/cryptodevices.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,26 @@ export function markAllDevicesKnown(matrixClient, devices) {
* @return {Promise} A promise which resolves to a map userId->deviceId->{@link
* module:crypto~DeviceInfo|DeviceInfo}.
*/
export function getUnknownDevicesForRoom(matrixClient, room) {
const roomMembers = room.getEncryptionTargetMembers().map((m) => {
export async function getUnknownDevicesForRoom(matrixClient, room) {
const roomMembers = await room.getEncryptionTargetMembers().map((m) => {
return m.userId;
});
return matrixClient.downloadKeys(roomMembers, false).then((devices) => {
const unknownDevices = {};
// This is all devices in this room, so find the unknown ones.
Object.keys(devices).forEach((userId) => {
Object.keys(devices[userId]).map((deviceId) => {
const device = devices[userId][deviceId];
const devices = await matrixClient.downloadKeys(roomMembers, false);
const unknownDevices = {};
// This is all devices in this room, so find the unknown ones.
Object.keys(devices).forEach((userId) => {
Object.keys(devices[userId]).map((deviceId) => {
const device = devices[userId][deviceId];

if (device.isUnverified() && !device.isKnown()) {
if (unknownDevices[userId] === undefined) {
unknownDevices[userId] = {};
}
unknownDevices[userId][deviceId] = device;
if (device.isUnverified() && !device.isKnown()) {
if (unknownDevices[userId] === undefined) {
unknownDevices[userId] = {};
}
});
unknownDevices[userId][deviceId] = device;
}
});
return unknownDevices;
});
return unknownDevices;
}

function focusComposer() {
Expand Down
2 changes: 1 addition & 1 deletion test/components/views/rooms/RoomList-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function generateRoomId() {

describe('RoomList', () => {
function createRoom(opts) {
const room = new Room(generateRoomId(), client.getUserId());
const room = new Room(generateRoomId(), null, client.getUserId());
if (opts) {
Object.assign(room, opts);
}
Expand Down