Get all mailbox cache by AccountId
(cherry picked from commit 8a7ccbf5d757ac9f1ffbd1fc5a1c863f30ab7b4c)
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_config.dart';
|
||||
import 'package:tmail_ui_user/features/caching/utils/cache_utils.dart';
|
||||
|
||||
abstract class HiveCacheClient<T> {
|
||||
|
||||
@@ -77,6 +79,21 @@ abstract class HiveCacheClient<T> {
|
||||
});
|
||||
}
|
||||
|
||||
Future<List<T>> getListByCollectionId(String collectionId) {
|
||||
return Future.sync(() async {
|
||||
final boxItem = encryption ? await openBoxEncryption() : await openBox();
|
||||
return boxItem.toMap()
|
||||
.where((key, value) {
|
||||
final tupleKey = TupleKey.fromString(key as String);
|
||||
return tupleKey.parts.length >= 2 && tupleKey.parts[1] == collectionId;
|
||||
})
|
||||
.values
|
||||
.toList();
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> updateItem(String key, T newObject) {
|
||||
return Future.sync(() async {
|
||||
final boxItem = encryption
|
||||
|
||||
Reference in New Issue
Block a user