forked from mystiq/hydrogen-web
attempt at fixing https://github.com/vector-im/hydrogen-web/issues/245
This commit is contained in:
parent
e29bc6710a
commit
56db210763
2 changed files with 11 additions and 4 deletions
|
@ -80,14 +80,16 @@ export class RoomEncryption {
|
||||||
}
|
}
|
||||||
|
|
||||||
async writeMemberChanges(memberChanges, txn) {
|
async writeMemberChanges(memberChanges, txn) {
|
||||||
|
let shouldFlush;
|
||||||
const memberChangesArray = Array.from(memberChanges.values());
|
const memberChangesArray = Array.from(memberChanges.values());
|
||||||
if (memberChangesArray.some(m => m.hasLeft)) {
|
if (memberChangesArray.some(m => m.hasLeft)) {
|
||||||
this._megolmEncryption.discardOutboundSession(this._room.id, txn);
|
this._megolmEncryption.discardOutboundSession(this._room.id, txn);
|
||||||
}
|
}
|
||||||
if (memberChangesArray.some(m => m.hasJoined)) {
|
if (memberChangesArray.some(m => m.hasJoined)) {
|
||||||
await this._addShareRoomKeyOperationForNewMembers(memberChangesArray, txn);
|
shouldFlush = await this._addShareRoomKeyOperationForNewMembers(memberChangesArray, txn);
|
||||||
}
|
}
|
||||||
await this._deviceTracker.writeMemberChanges(this._room, memberChanges, txn);
|
await this._deviceTracker.writeMemberChanges(this._room, memberChanges, txn);
|
||||||
|
return shouldFlush;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this happens before entries exists, as they are created by the syncwriter
|
// this happens before entries exists, as they are created by the syncwriter
|
||||||
|
@ -314,7 +316,9 @@ export class RoomEncryption {
|
||||||
this._room.id, txn);
|
this._room.id, txn);
|
||||||
if (roomKeyMessage) {
|
if (roomKeyMessage) {
|
||||||
this._writeRoomKeyShareOperation(roomKeyMessage, userIds, txn);
|
this._writeRoomKeyShareOperation(roomKeyMessage, userIds, txn);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_writeRoomKeyShareOperation(roomKeyMessage, userIds, txn) {
|
_writeRoomKeyShareOperation(roomKeyMessage, userIds, txn) {
|
||||||
|
|
|
@ -232,9 +232,11 @@ export class Room extends EventEmitter {
|
||||||
}
|
}
|
||||||
decryption.applyToEntries(entries);
|
decryption.applyToEntries(entries);
|
||||||
}
|
}
|
||||||
|
let shouldFlushKeyShares = false;
|
||||||
// pass member changes to device tracker
|
// pass member changes to device tracker
|
||||||
if (roomEncryption && this.isTrackingMembers && memberChanges?.size) {
|
if (roomEncryption && this.isTrackingMembers && memberChanges?.size) {
|
||||||
await roomEncryption.writeMemberChanges(memberChanges, txn);
|
shouldFlushKeyShares = await roomEncryption.writeMemberChanges(memberChanges, txn);
|
||||||
|
log.set("shouldFlushKeyShares", shouldFlushKeyShares);
|
||||||
}
|
}
|
||||||
// also apply (decrypted) timeline entries to the summary changes
|
// also apply (decrypted) timeline entries to the summary changes
|
||||||
summaryChanges = summaryChanges.applyTimelineEntries(
|
summaryChanges = summaryChanges.applyTimelineEntries(
|
||||||
|
@ -263,6 +265,7 @@ export class Room extends EventEmitter {
|
||||||
removedPendingEvents,
|
removedPendingEvents,
|
||||||
memberChanges,
|
memberChanges,
|
||||||
heroChanges,
|
heroChanges,
|
||||||
|
shouldFlushKeyShares,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,8 +317,8 @@ export class Room extends EventEmitter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
needsAfterSyncCompleted({memberChanges}) {
|
needsAfterSyncCompleted({shouldFlushKeyShares}) {
|
||||||
return this._roomEncryption?.needsToShareKeys(memberChanges);
|
return shouldFlushKeyShares;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue