refactor: Add verbose logs and refactor something

This commit is contained in:
Christian Pauly 2021-01-05 14:44:15 +01:00
parent 877245f146
commit e806bb9770
1 changed files with 20 additions and 11 deletions

View File

@ -456,21 +456,29 @@ class Bootstrap {
// aaaand set the SSSS secrets // aaaand set the SSSS secrets
final futures = <Future<void>>[]; final futures = <Future<void>>[];
if (masterKey != null) { if (masterKey != null) {
futures.add(client.onSync.stream.firstWhere((syncUpdate) => futures.add(
client.userDeviceKeys.containsKey(client.userID) && client.onSync.stream
client.userDeviceKeys[client.userID].masterKey != null && .firstWhere((syncUpdate) =>
client.userDeviceKeys[client.userID].masterKey.ed25519Key == client.userDeviceKeys.containsKey(client.userID) &&
masterKey.publicKey)); client.userDeviceKeys[client.userID].masterKey != null &&
client.userDeviceKeys[client.userID].masterKey.ed25519Key ==
masterKey.publicKey)
.then((_) => Logs().v('New Master Key was created')),
);
} }
for (final entry in secretsToStore.entries) { for (final entry in secretsToStore.entries) {
futures.add(client.onSync.stream.firstWhere((syncUpdate) => syncUpdate futures.add(
.accountData client.onSync.stream
.any((accountData) => accountData.type == entry.key))); .firstWhere((syncUpdate) => syncUpdate.accountData
.any((accountData) => accountData.type == entry.key))
.then((_) =>
Logs().v('New Key with type ${entry.key} was created')),
);
await newSsssKey.store(entry.key, entry.value); await newSsssKey.store(entry.key, entry.value);
} }
for (final f in futures) { Logs().v(
await f; 'Wait for MasterKey and ${secretsToStore.entries.length} keys to be created');
} await Future.wait<void>(futures);
final keysToSign = <SignableKey>[]; final keysToSign = <SignableKey>[];
if (masterKey != null) { if (masterKey != null) {
if (client.userDeviceKeys[client.userID].masterKey.ed25519Key != if (client.userDeviceKeys[client.userID].masterKey.ed25519Key !=
@ -558,6 +566,7 @@ class Bootstrap {
} }
set state(BootstrapState newState) { set state(BootstrapState newState) {
Logs().v('BootstrapState', newState);
if (state != BootstrapState.error) { if (state != BootstrapState.error) {
_state = newState; _state = newState;
} }