mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-23 22:12:34 +01:00
feat: Test FluffyBox store
This commit is contained in:
parent
d9263e775d
commit
db013043a7
@ -5,8 +5,8 @@ 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:sembast/sembast.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:sembast/sembast.dart';
|
||||
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'famedlysdk_store.dart';
|
||||
@ -80,7 +80,7 @@ abstract class ClientManager {
|
||||
KeyVerificationMethod.emoji,
|
||||
},
|
||||
importantStateEvents: <String>{'im.ponies.room_emotes'},
|
||||
databaseBuilder: FluffyBoxDatabase.databaseBuilder,
|
||||
databaseBuilder: FlutterFluffyBoxDatabase.databaseBuilder,
|
||||
legacyDatabaseBuilder: FlutterMatrixSembastDatabase.databaseBuilder,
|
||||
supportedLoginTypes: {
|
||||
AuthenticationTypes.password,
|
||||
|
@ -3,27 +3,23 @@ import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/foundation.dart' hide Key;
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:idb_shim/idb_browser.dart';
|
||||
import 'package:idb_shim/idb.dart' hide Event;
|
||||
import 'package:sqflite/sqflite.dart' as sqflite;
|
||||
|
||||
import 'package:encrypt/encrypt.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:idb_sqflite/idb_sqflite.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:sqflite/sqflite.dart' as sqflite;
|
||||
|
||||
import '../platform_infos.dart';
|
||||
|
||||
class FluffyBoxDatabase extends MatrixIndexedDatabase {
|
||||
FluffyBoxDatabase(
|
||||
class FlutterFluffyBoxDatabase extends FluffyBoxDatabase {
|
||||
FlutterFluffyBoxDatabase(
|
||||
String name, {
|
||||
String path,
|
||||
IdbFactory dbFactory,
|
||||
Future<sqflite.Database> Function() openSqlDatabase,
|
||||
}) : super(
|
||||
name,
|
||||
path,
|
||||
factory: dbFactory,
|
||||
openSqlDatabase: openSqlDatabase,
|
||||
);
|
||||
|
||||
static const String _cipherStorageKey = 'database_encryption_key';
|
||||
@ -54,21 +50,17 @@ class FluffyBoxDatabase extends MatrixIndexedDatabase {
|
||||
}
|
||||
|
||||
final db = FluffyBoxDatabase(
|
||||
'FluffyBox-${client.clientName}',
|
||||
path: await _findDatabasePath(client),
|
||||
dbFactory: factory,
|
||||
'fluffybox_${client.clientName.replaceAll(' ', '_').toLowerCase()}',
|
||||
openSqlDatabase: () => _openSqlDatabase(client),
|
||||
);
|
||||
await db.open();
|
||||
Logs().d('FluffyBox is ready');
|
||||
return db;
|
||||
}
|
||||
|
||||
static IdbFactory get factory {
|
||||
if (kIsWeb) return idbFactoryBrowser;
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
return getIdbFactorySqflite(sqflite.databaseFactory);
|
||||
}
|
||||
return idbFactoryNative;
|
||||
static Future<sqflite.Database> _openSqlDatabase(Client client) async {
|
||||
final path = await _findDatabasePath(client);
|
||||
return await sqflite.openDatabase(path);
|
||||
}
|
||||
|
||||
static Future<String> _findDatabasePath(Client client) async {
|
||||
@ -84,7 +76,8 @@ class FluffyBoxDatabase extends MatrixIndexedDatabase {
|
||||
directory = Directory.current;
|
||||
}
|
||||
}
|
||||
path = '${directory.path}${client.clientName}.db';
|
||||
path =
|
||||
'${directory.path}${client.clientName.replaceAll(' ', '-')}.sqflite';
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
27
pubspec.lock
27
pubspec.lock
@ -351,6 +351,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.2"
|
||||
fluffybox:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fluffybox
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.0"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@ -782,7 +789,7 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: "krille/idb"
|
||||
resolved-ref: "5996f6bb01ba1110c1f8fb84c39dd6bcf0d2900a"
|
||||
resolved-ref: aee9bbf8afd1114a25ad547822d2e3eda6c73c83
|
||||
url: "https://gitlab.com/famedly/company/frontend/famedlysdk.git"
|
||||
source: git
|
||||
version: "0.7.0-nullsafety.6"
|
||||
@ -1317,7 +1324,14 @@ packages:
|
||||
name: sqflite_common
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0+2"
|
||||
version: "2.0.1+1"
|
||||
sqflite_common_ffi:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sqflite_common_ffi
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
sqflite_sqlcipher:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -1325,6 +1339,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
sqlite3:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sqlite3
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1669,5 +1690,5 @@ packages:
|
||||
source: hosted
|
||||
version: "3.1.0"
|
||||
sdks:
|
||||
dart: ">=2.14.0 <3.0.0"
|
||||
dart: ">=2.14.4 <3.0.0"
|
||||
flutter: ">=2.5.0"
|
||||
|
Loading…
Reference in New Issue
Block a user