diff --git a/lib/src/client.dart b/lib/src/client.dart index 45025acf..a3cec5d6 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -1579,13 +1579,13 @@ sort order of ${prevState.sortOrder}. This should never happen...'''); /// you can safely make this Client instance null. Future 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) { diff --git a/lib/src/room.dart b/lib/src/room.dart index 7b46b889..aba01d2d 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -1620,7 +1620,8 @@ class Room { var 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); diff --git a/test/user_test.dart b/test/user_test.dart index ea2d7feb..fdb8c0b3 100644 --- a/test/user_test.dart +++ b/test/user_test.dart @@ -133,7 +133,7 @@ void main() { expect(user1.canChangePowerLevel, false); }); test('dispose client', () async { - await client.dispose(); + await client.dispose(closeDatabase: true); }); }); }