refactor: (BREAKING) Remove hive database and hive dependencies
This commit is contained in:
parent
f6750feeed
commit
5ec745915e
|
|
@ -26,7 +26,6 @@ export 'fake_matrix_api.dart' show FakeMatrixApi;
|
||||||
export 'src/client.dart';
|
export 'src/client.dart';
|
||||||
export 'src/database/database_api.dart';
|
export 'src/database/database_api.dart';
|
||||||
export 'src/database/matrix_sdk_database.dart';
|
export 'src/database/matrix_sdk_database.dart';
|
||||||
export 'src/database/hive_collections_database.dart';
|
|
||||||
export 'src/database/sqflite_encryption_helper.dart';
|
export 'src/database/sqflite_encryption_helper.dart';
|
||||||
export 'src/event.dart';
|
export 'src/event.dart';
|
||||||
export 'src/presence.dart';
|
export 'src/presence.dart';
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1816,3 +1816,28 @@ class MatrixSdkDatabase extends DatabaseApi with DatabaseFileStorage {
|
||||||
profile.toJson(),
|
profile.toJson(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TupleKey {
|
||||||
|
final List<String> parts;
|
||||||
|
|
||||||
|
TupleKey(String key1, [String? key2, String? key3])
|
||||||
|
: parts = [
|
||||||
|
key1,
|
||||||
|
if (key2 != null) key2,
|
||||||
|
if (key3 != null) key3,
|
||||||
|
];
|
||||||
|
|
||||||
|
const TupleKey.byParts(this.parts);
|
||||||
|
|
||||||
|
TupleKey.fromString(String multiKeyString)
|
||||||
|
: parts = multiKeyString.split('|').toList();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => parts.join('|');
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(other) => parts.toString() == other.toString();
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hashAll(parts);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ dependencies:
|
||||||
crypto: ^3.0.0
|
crypto: ^3.0.0
|
||||||
enhanced_enum: ^0.2.4
|
enhanced_enum: ^0.2.4
|
||||||
ffi: ^2.0.0
|
ffi: ^2.0.0
|
||||||
hive: ^2.2.3
|
|
||||||
html: ^0.15.0
|
html: ^0.15.0
|
||||||
html_unescape: ^2.0.0
|
html_unescape: ^2.0.0
|
||||||
http: ">=0.13.0 <2.0.0"
|
http: ">=0.13.0 <2.0.0"
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,7 @@ String createLargeString(String character, int desiredSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
final databaseBuilders = {
|
final databaseBuilders = {'Matrix SDK Database': getMatrixSdkDatabase};
|
||||||
'Matrix SDK Database': getMatrixSdkDatabase,
|
|
||||||
'Hive Collections Database': getHiveCollectionsDatabase,
|
|
||||||
};
|
|
||||||
|
|
||||||
for (final databaseBuilder in databaseBuilders.entries) {
|
for (final databaseBuilder in databaseBuilders.entries) {
|
||||||
group('Test ${databaseBuilder.key}', tags: 'olm', () {
|
group('Test ${databaseBuilder.key}', tags: 'olm', () {
|
||||||
|
|
@ -673,19 +670,14 @@ void main() {
|
||||||
updated: DateTime.now(),
|
updated: DateTime.now(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
// ignore: deprecated_member_use_from_same_package
|
final profile2 = await database.getUserProfile('@alice:example.com');
|
||||||
if (database is! HiveCollectionsDatabase) {
|
expect(profile2?.displayname, 'Alice M');
|
||||||
final profile2 =
|
expect(profile2?.outdated, false);
|
||||||
await database.getUserProfile('@alice:example.com');
|
await database.markUserProfileAsOutdated('@alice:example.com');
|
||||||
expect(profile2?.displayname, 'Alice M');
|
|
||||||
expect(profile2?.outdated, false);
|
|
||||||
await database.markUserProfileAsOutdated('@alice:example.com');
|
|
||||||
|
|
||||||
final profile3 =
|
final profile3 = await database.getUserProfile('@alice:example.com');
|
||||||
await database.getUserProfile('@alice:example.com');
|
expect(profile3?.displayname, 'Alice M');
|
||||||
expect(profile3?.displayname, 'Alice M');
|
expect(profile3?.outdated, true);
|
||||||
expect(profile3?.outdated, true);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,6 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import 'package:file/local.dart';
|
|
||||||
import 'package:hive/hive.dart';
|
|
||||||
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
||||||
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
|
|
@ -25,25 +23,6 @@ import 'package:matrix/matrix.dart';
|
||||||
Future<DatabaseApi> getDatabase(Client? c, {String? databasePath}) =>
|
Future<DatabaseApi> getDatabase(Client? c, {String? databasePath}) =>
|
||||||
getMatrixSdkDatabase(c, path: databasePath);
|
getMatrixSdkDatabase(c, path: databasePath);
|
||||||
|
|
||||||
bool hiveInitialized = false;
|
|
||||||
|
|
||||||
// ignore: deprecated_member_use_from_same_package
|
|
||||||
Future<HiveCollectionsDatabase> getHiveCollectionsDatabase(Client? c) async {
|
|
||||||
final testHivePath = await LocalFileSystem()
|
|
||||||
.systemTempDirectory
|
|
||||||
.createTemp('dart-sdk-tests-database');
|
|
||||||
if (!hiveInitialized) {
|
|
||||||
Hive.init(testHivePath.path);
|
|
||||||
}
|
|
||||||
// ignore: deprecated_member_use_from_same_package
|
|
||||||
final db = HiveCollectionsDatabase(
|
|
||||||
'unit_test.${c?.hashCode}',
|
|
||||||
testHivePath.path,
|
|
||||||
);
|
|
||||||
await db.open();
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ignore: deprecated_member_use_from_same_package
|
// ignore: deprecated_member_use_from_same_package
|
||||||
Future<MatrixSdkDatabase> getMatrixSdkDatabase(
|
Future<MatrixSdkDatabase> getMatrixSdkDatabase(
|
||||||
Client? c, {
|
Client? c, {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:hive/hive.dart';
|
|
||||||
import 'package:olm/olm.dart' as olm;
|
import 'package:olm/olm.dart' as olm;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
|
@ -40,8 +39,6 @@ void main() => group(
|
||||||
Client? testClientA, testClientB;
|
Client? testClientA, testClientB;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Hive.init(null);
|
|
||||||
|
|
||||||
await olm.init();
|
await olm.init();
|
||||||
olm.Account();
|
olm.Account();
|
||||||
Logs().i('[LibOlm] Enabled');
|
Logs().i('[LibOlm] Enabled');
|
||||||
|
|
@ -488,8 +485,6 @@ void main() => group(
|
||||||
Client? testClientA, testClientB;
|
Client? testClientA, testClientB;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Hive.init(null);
|
|
||||||
|
|
||||||
await olm.init();
|
await olm.init();
|
||||||
olm.Account();
|
olm.Account();
|
||||||
Logs().i('[LibOlm] Enabled');
|
Logs().i('[LibOlm] Enabled');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue