refactor: Key manager megolm handling to make key generation more efficient

This commit is contained in:
Christian Pauly 2022-12-14 08:59:36 +01:00
parent dd7cf5c1bf
commit c66d2edb5e
1 changed files with 9 additions and 0 deletions

View File

@ -382,6 +382,15 @@ class KeyManager {
.where((e) => !e.value)
.map((e) => e.key))
: <String>{};
// check if a device got removed
if (oldDeviceIds.difference(newDeviceIds).isNotEmpty) {
print("Device deleted, rotating megolm session");
wipe = true;
break;
}
// check if any new devices need keys
final newDevices = newDeviceIds.difference(oldDeviceIds);
if (newDeviceIds.isNotEmpty) {
devicesToReceive.addAll(newDeviceKeys.where(