diff --git a/lib/encryption/utils/bootstrap.dart b/lib/encryption/utils/bootstrap.dart index 184d14f1..d17d3081 100644 --- a/lib/encryption/utils/bootstrap.dart +++ b/lib/encryption/utils/bootstrap.dart @@ -581,6 +581,17 @@ class Bootstrap { ); Logs().v('Store the secret...'); await newSsssKey?.store(megolmKey, base64.encode(privKey)); + Logs().v('Wait for secret to come down sync'); + + if (!await encryption.keyManager.isCached()) { + await client.onSync.stream + .firstWhere((syncUpdate) => + syncUpdate.accountData != null && + syncUpdate.accountData! + .any((accountData) => accountData.type == megolmKey)) + .then((_) => Logs().v('New backup key was created')); + } + Logs().v( 'And finally set all megolm keys as needing to be uploaded again...'); await client.database?.markInboundGroupSessionsAsNeedingUpload();