diff --git a/lib/utils/client_manager.dart b/lib/utils/client_manager.dart index 1ee71d491..1a4e93a31 100644 --- a/lib/utils/client_manager.dart +++ b/lib/utils/client_manager.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:flutter/foundation.dart'; import 'package:hive_flutter/hive_flutter.dart'; +import 'package:idb_shim/idb_io.dart'; import 'package:matrix/encryption/utils/key_verification.dart'; import 'package:matrix/matrix.dart'; import 'package:path_provider/path_provider.dart'; @@ -109,7 +110,18 @@ abstract class ClientManager { EventTypes.RoomPowerLevels, }, logLevel: kReleaseMode ? Level.warning : Level.verbose, - databaseBuilder: FlutterHiveCollectionsDatabase.databaseBuilder, + databaseBuilder: (client) async { + final path = + await FlutterHiveCollectionsDatabase.findDatabasePath(client); + Logs().v('Store data at:', path); + final db = EasyIdbDatabase( + 'database_${client.clientName.replaceAll(' ', '_').toLowerCase()}', + factory: getIdbFactoryPersistent(path), + ); + await db.open(); + return db; + }, + legacyDatabaseBuilder: FlutterHiveCollectionsDatabase.databaseBuilder, supportedLoginTypes: { AuthenticationTypes.password, AuthenticationTypes.sso, diff --git a/lib/utils/matrix_sdk_extensions/flutter_hive_collections_database.dart b/lib/utils/matrix_sdk_extensions/flutter_hive_collections_database.dart index 932763c5d..56a2d2da0 100644 --- a/lib/utils/matrix_sdk_extensions/flutter_hive_collections_database.dart +++ b/lib/utils/matrix_sdk_extensions/flutter_hive_collections_database.dart @@ -63,7 +63,7 @@ class FlutterHiveCollectionsDatabase extends HiveCollectionsDatabase { final db = FlutterHiveCollectionsDatabase( 'hive_collections_${client.clientName.replaceAll(' ', '_').toLowerCase()}', - await _findDatabasePath(client), + await findDatabasePath(client), key: hiverCipher, ); try { @@ -79,7 +79,7 @@ class FlutterHiveCollectionsDatabase extends HiveCollectionsDatabase { return db; } - static Future _findDatabasePath(Client client) async { + static Future findDatabasePath(Client client) async { String path = client.clientName; if (!kIsWeb) { Directory directory; diff --git a/pubspec.lock b/pubspec.lock index 2c861904a..c52e10d2c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -345,6 +345,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.6.2" + easy_idb: + dependency: transitive + description: + name: easy_idb + sha256: "06c3e834f2d42cc20d78caf44441b3125767961d7687f58b56385ee8f7fcbd61" + url: "https://pub.dev" + source: hosted + version: "1.0.0" emoji_picker_flutter: dependency: "direct main" description: @@ -858,6 +866,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + idb_shim: + dependency: "direct main" + description: + name: idb_shim + sha256: "3ac9d6a90c29e2192d35c8386d7b20cb3865756f5b299d74a829d5b888776d26" + url: "https://pub.dev" + source: hosted + version: "2.3.0+2" image: dependency: transitive description: @@ -1059,11 +1075,12 @@ packages: matrix: dependency: "direct main" description: - name: matrix - sha256: "2b07709bce975d2be4dc4cd3cc1196fcd6c0397d4e250b42a498e35523fc28f3" - url: "https://pub.dev" - source: hosted - version: "0.20.1" + path: "." + ref: "krille/easy_idb_database" + resolved-ref: "44c9a17961c46e6c1e8f9367fa210cea4953cadb" + url: "https://gitlab.com/famedly/company/frontend/famedlysdk.git" + source: git + version: "0.18.3" matrix_api_lite: dependency: transitive description: @@ -1576,6 +1593,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.3.2" + sembast: + dependency: transitive + description: + name: sembast + sha256: "24829715d11c2c437e67b413f29ff91b5325daa9632f851d44deeea7a29bde9e" + url: "https://pub.dev" + source: hosted + version: "3.4.3+1" sentiment_dart: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 2c8e50026..bd4bb841c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -51,6 +51,7 @@ dependencies: hive: ^2.2.3 hive_flutter: ^1.1.0 http: ^0.13.4 + idb_shim: ^2.3.0+2 image_picker: ^0.8.4+8 intl: any just_audio: ^0.9.30 @@ -166,3 +167,5 @@ dependency_overrides: git: url: https://github.com/TheOneWithTheBraid/keyboard_shortcuts.git ref: null-safety + matrix: + path: ../famedlysdk/