fix: Messages being encrypted for too many devices

This commit is contained in:
Sorunome 2020-10-04 12:16:01 +02:00
parent ae79af6ea8
commit 74bd1d331b
No known key found for this signature in database
GPG key ID: B19471D07FC9BE9C
3 changed files with 5 additions and 4 deletions

View file

@ -1579,13 +1579,13 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
/// you can safely make this Client instance null.
Future<void> dispose({bool closeDatabase = false}) async {
_disposed = true;
encryption?.dispose();
encryption = null;
try {
await _currentTransaction;
} catch (_) {
// No-OP
}
encryption?.dispose();
encryption = null;
try {
if (closeDatabase) await database?.close();
} catch (error, stacktrace) {

View file

@ -1620,7 +1620,8 @@ class Room {
var deviceKeys = <DeviceKeys>[];
var users = await requestParticipants();
for (final user in users) {
if (client.userDeviceKeys.containsKey(user.id)) {
if ([Membership.invite, Membership.join].contains(user.membership) &&
client.userDeviceKeys.containsKey(user.id)) {
for (var deviceKeyEntry
in client.userDeviceKeys[user.id].deviceKeys.values) {
deviceKeys.add(deviceKeyEntry);

View file

@ -133,7 +133,7 @@ void main() {
expect(user1.canChangePowerLevel, false);
});
test('dispose client', () async {
await client.dispose();
await client.dispose(closeDatabase: true);
});
});
}