mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 14:59:29 +01:00
chore: Add some stats for app start
This commit is contained in:
parent
3126ce27f9
commit
abfe6a138b
@ -11,6 +11,7 @@ linter:
|
||||
|
||||
analyzer:
|
||||
errors:
|
||||
implementation_imports: ignore
|
||||
todo: ignore
|
||||
exclude:
|
||||
- lib/generated_plugin_registrant.dart
|
||||
|
@ -37,7 +37,7 @@ void main() async {
|
||||
Zone.current.handleUncaughtError(details.exception, details.stack);
|
||||
|
||||
final clients = await ClientManager.getClients();
|
||||
Logs().level = kReleaseMode ? Level.info : Level.verbose;
|
||||
Logs().level = kReleaseMode ? Level.debug : Level.verbose;
|
||||
|
||||
if (PlatformInfos.isMobile) {
|
||||
BackgroundPush.clientOnly(clients.first);
|
||||
|
@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:matrix/encryption/utils/key_verification.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:matrix/src/utils/run_benchmarked.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
@ -22,7 +23,10 @@ abstract class ClientManager {
|
||||
}
|
||||
final clientNames = <String>{};
|
||||
try {
|
||||
final rawClientNames = await Store().getItem(clientNamespace);
|
||||
final rawClientNames = await runBenchmarked(
|
||||
'Get client names',
|
||||
() => Store().getItem(clientNamespace),
|
||||
);
|
||||
if (rawClientNames != null) {
|
||||
final clientNamesList =
|
||||
(jsonDecode(rawClientNames) as List).cast<String>();
|
||||
@ -37,11 +41,12 @@ abstract class ClientManager {
|
||||
await Store().setItem(clientNamespace, jsonEncode(clientNames.toList()));
|
||||
}
|
||||
final clients = clientNames.map(createClient).toList();
|
||||
await Future.wait(clients.map((client) => client
|
||||
.init(
|
||||
waitForFirstSync: false,
|
||||
waitUntilLoadCompletedLoaded: false,
|
||||
)
|
||||
await Future.wait(clients.map((client) => runBenchmarked(
|
||||
'Init client ${client.clientName}',
|
||||
() => client.init(
|
||||
waitForFirstSync: false,
|
||||
waitUntilLoadCompletedLoaded: false,
|
||||
))
|
||||
.catchError((e, s) => Logs().e('Unable to initialize client', e, s))));
|
||||
if (clients.length > 1 && clients.any((c) => !c.isLogged())) {
|
||||
final loggedOutClients = clients.where((c) => !c.isLogged()).toList();
|
||||
@ -51,7 +56,11 @@ abstract class ClientManager {
|
||||
clientNames.remove(client.clientName);
|
||||
clients.remove(client);
|
||||
}
|
||||
await Store().setItem(clientNamespace, jsonEncode(clientNames.toList()));
|
||||
await runBenchmarked(
|
||||
'Update clientNamespaces',
|
||||
() =>
|
||||
Store().setItem(clientNamespace, jsonEncode(clientNames.toList())),
|
||||
);
|
||||
}
|
||||
return clients;
|
||||
}
|
||||
|
@ -65,14 +65,8 @@ class FlutterMatrixSembastDatabase extends MatrixSembastDatabase {
|
||||
path: await _findDatabasePath(client),
|
||||
dbFactory: kIsWeb ? databaseFactoryWeb : databaseFactoryIo,
|
||||
);
|
||||
try {
|
||||
await db.open();
|
||||
Logs().d('Sembast is ready');
|
||||
} catch (e, s) {
|
||||
Logs().e('Unable to open Sembast. Delete and try again...', e, s);
|
||||
await db.clear();
|
||||
await db.open();
|
||||
}
|
||||
await db.open();
|
||||
Logs().d('Sembast is ready');
|
||||
return db;
|
||||
}
|
||||
|
||||
@ -91,7 +85,6 @@ class FlutterMatrixSembastDatabase extends MatrixSembastDatabase {
|
||||
}
|
||||
path = '${directory.path}${client.clientName}.db';
|
||||
}
|
||||
Logs().i('Use database path: "$path"');
|
||||
return path;
|
||||
}
|
||||
|
||||
|
10
pubspec.lock
10
pubspec.lock
@ -773,12 +773,10 @@ packages:
|
||||
matrix:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: "krille/sembast"
|
||||
resolved-ref: "28af05289a6d48cbe6067031bdf08ab72fb21225"
|
||||
url: "https://gitlab.com/famedly/company/frontend/famedlysdk.git"
|
||||
source: git
|
||||
version: "0.7.0-nullsafety.5"
|
||||
name: matrix
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.7.0-nullsafety.6"
|
||||
matrix_api_lite:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -46,7 +46,7 @@ dependencies:
|
||||
intl: any
|
||||
localstorage: ^4.0.0+1
|
||||
lottie: ^1.2.1
|
||||
matrix: ^0.7.0-nullsafety.5
|
||||
matrix: ^0.7.0-nullsafety.6
|
||||
matrix_link_text: ^1.0.2
|
||||
native_imaging:
|
||||
git: https://gitlab.com/famedly/libraries/native_imaging.git
|
||||
@ -115,8 +115,4 @@ dependency_overrides:
|
||||
hosted:
|
||||
name: geolocator_android
|
||||
url: https://hanntech-gmbh.gitlab.io/free2pass/flutter-geolocator-floss
|
||||
matrix:
|
||||
git:
|
||||
url: https://gitlab.com/famedly/company/frontend/famedlysdk.git
|
||||
ref: krille/sembast
|
||||
provider: 5.0.0
|
||||
|
Loading…
Reference in New Issue
Block a user