fix: Start-up time waits for first sync

This commit is contained in:
Krille Fear 2021-09-20 11:52:02 +02:00
commit ac342624f6
3 changed files with 21 additions and 10 deletions

View file

@ -32,12 +32,18 @@ abstract class ClientManager {
}
if (clientNames.isEmpty) clientNames.add(PlatformInfos.clientName);
final clients = clientNames.map(createClient).toList();
final start = DateTime.now();
await Future.wait(clients.map((client) => client
.init()
.init(waitForFirstSync: false)
.catchError((e, s) => Logs().e('Unable to initialize client', e, s))));
final end = DateTime.now();
print(
'We needed: ${end.millisecondsSinceEpoch - start.millisecondsSinceEpoch} milliseconds');
if (clients.length > 1 && clients.any((c) => !c.isLogged())) {
final loggedOutClients = clients.where((c) => !c.isLogged()).toList();
for (final client in loggedOutClients) {
Logs().w(
'Multi account is enabled but client ${client.userID} is not logged in. Removing...');
clientNames.remove(client.clientName);
clients.remove(client);
}