Skip to content

Commit 6fb6165

Browse files
committed
fix: check if secrets are cached instead of checking sync
chore: allow passing a timeout value to oneShotSync
1 parent 5900442 commit 6fb6165

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

lib/encryption/ssss.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,10 @@ class OpenSSSS {
747747
throw Exception('SSSS not unlocked');
748748
}
749749
await ssss.store(type, secret, keyId, privateKey, add: add);
750+
751+
while (!(await ssss.encryption.keyManager.isCached())) {
752+
await ssss.client.oneShotSync(timeout: Duration(seconds: 5));
753+
}
750754
}
751755

752756
Future<void> validateAndStripOtherKeys(String type, String secret) async {

lib/encryption/utils/bootstrap.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -581,14 +581,6 @@ class Bootstrap {
581581
);
582582
Logs().v('Store the secret...');
583583
await newSsssKey?.store(megolmKey, base64.encode(privKey));
584-
Logs().v('Wait for secret to come down sync');
585-
586-
if (!await encryption.keyManager.isCached()) {
587-
await client.onSync.stream.firstWhere((syncUpdate) =>
588-
syncUpdate.accountData != null &&
589-
syncUpdate.accountData!
590-
.any((accountData) => accountData.type == megolmKey));
591-
}
592584

593585
Logs().v(
594586
'And finally set all megolm keys as needing to be uploaded again...');

lib/src/client.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,8 +1625,8 @@ class Client extends MatrixApi {
16251625

16261626
/// Immediately start a sync and wait for completion.
16271627
/// If there is an active sync already, wait for the active sync instead.
1628-
Future<void> oneShotSync() {
1629-
return _sync();
1628+
Future<void> oneShotSync({Duration? timeout}) {
1629+
return _sync(timeout: timeout);
16301630
}
16311631

16321632
/// Pass a timeout to set how long the server waits before sending an empty response.

0 commit comments

Comments
 (0)