Merge branch 'krille/pass-box-collection-opener' into 'main'

feat: Make possible to overwrite boxcollection opener in Hive Collections Database

See merge request famedly/company/frontend/famedlysdk!1252
This commit is contained in:
Nicolas Werner 2023-03-20 12:50:42 +00:00
commit f2e1e52531
1 changed files with 13 additions and 2 deletions

View File

@ -38,6 +38,12 @@ class HiveCollectionsDatabase extends DatabaseApi {
final String name;
final String? path;
final HiveCipher? key;
final Future<BoxCollection> Function(
String name,
Set<String> boxNames, {
String? path,
HiveCipher? key,
}) collectionFactory;
late BoxCollection _collection;
late CollectionBox<String> _clientBox;
late CollectionBox<Map> _accountDataBox;
@ -118,13 +124,18 @@ class HiveCollectionsDatabase extends DatabaseApi {
String get _seenDeviceKeysBoxName => 'box_seen_device_keys';
HiveCollectionsDatabase(this.name, this.path, {this.key});
HiveCollectionsDatabase(
this.name,
this.path, {
this.key,
this.collectionFactory = BoxCollection.open,
});
@override
int get maxFileSize => 0;
Future<void> open() async {
_collection = await BoxCollection.open(
_collection = await collectionFactory(
name,
{
_clientBoxName,