feat: Try out sembast database backend

This commit is contained in:
Krille 2023-04-20 13:51:50 +02:00
parent 74ef50af49
commit e029852381
No known key found for this signature in database
5 changed files with 54 additions and 12 deletions

View File

@ -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,

View File

@ -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<String> _findDatabasePath(Client client) async {
static Future<String> findDatabasePath(Client client) async {
String path = client.clientName;
if (!kIsWeb) {
Directory directory;

View File

@ -309,6 +309,6 @@ class MatrixLocals extends MatrixLocalizations {
String wasDirectChatDisplayName(String oldDisplayName) =>
l10n.wasDirectChatDisplayName(oldDisplayName);
//@override
@override
String get unknownUser => l10n.user;
}

View File

@ -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:
@ -857,6 +865,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:
@ -1066,19 +1082,20 @@ packages:
matrix:
dependency: "direct main"
description:
name: matrix
sha256: "8c07fa7b558d28891ea2609542295e4bb3e8360545540b434abaf055dde3a59c"
url: "https://pub.dev"
source: hosted
version: "0.18.0"
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:
name: matrix_api_lite
sha256: "7c1af53ccdcaf69db1372f607cba48f4ac360595c9bc9e1420768adb2f1c3814"
sha256: "16d74a065a085adf30985e6068c9cc001e130979d1f186e40f733450a6583725"
url: "https://pub.dev"
source: hosted
version: "1.1.10"
version: "1.6.1"
matrix_homeserver_recommendations:
dependency: "direct main"
description:
@ -1583,6 +1600,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:

View File

@ -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
@ -163,4 +164,8 @@ dependency_overrides:
keyboard_shortcuts:
git:
url: https://github.com/TheOneWithTheBraid/keyboard_shortcuts.git
ref: null-safety
ref: null-safety
matrix:
git:
url: https://gitlab.com/famedly/company/frontend/famedlysdk.git
ref: krille/easy_idb_database