TF-145 Add data layer for getAllEmail in Caching
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/model/email_cache.dart';
|
||||
|
||||
@@ -118,4 +119,17 @@ class EmailCacheClient extends HiveCacheClient<EmailCache> {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
Future<List<EmailCache>> getListEmailCacheByMailboxId(MailboxId mailboxId) {
|
||||
return Future.sync(() async {
|
||||
final boxEmail = await openBox();
|
||||
return boxEmail.values.where((emailCache) {
|
||||
return emailCache.mailboxIds != null
|
||||
&& emailCache.mailboxIds!.containsKey(mailboxId.id.value)
|
||||
&& emailCache.mailboxIds![mailboxId.id.value] == true;
|
||||
}).toList();
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user