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