fix: Hotfix create missing objectbox

This commit is contained in:
Krille 2024-05-21 13:07:36 +02:00
parent f66e14671b
commit f3e631b2eb
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652
3 changed files with 6 additions and 1 deletions

View File

@ -19,12 +19,15 @@ class BoxCollection with ZoneTransactionMixin {
Object? sqfliteDatabase,
Object? sqfliteFactory,
IdbFactory? idbFactory,
int version = 1,
}) async {
idbFactory ??= window.indexedDB!;
final db = await idbFactory.open(name, version: 1,
final db = await idbFactory.open(name, version: version,
onUpgradeNeeded: (VersionChangeEvent event) {
final db = event.target.result;
for (final name in boxNames) {
if (db.objectStoreNames.contains(name)) continue;
db.createObjectStore(name, autoIncrement: true);
}
});

View File

@ -218,6 +218,7 @@ class MatrixSdkDatabase extends DatabaseApi with DatabaseFileStorage {
sqfliteDatabase: database,
sqfliteFactory: sqfliteFactory,
idbFactory: idbFactory,
version: version,
);
_clientBox = _collection.openBox<String>(
_clientBoxName,

View File

@ -20,6 +20,7 @@ class BoxCollection with ZoneTransactionMixin {
Object? sqfliteDatabase,
DatabaseFactory? sqfliteFactory,
dynamic idbFactory,
int version = 1,
}) async {
if (sqfliteDatabase is! Database) {
throw ('You must provide a Database `sqfliteDatabase` for use on native.');