Use TupleKey(ObjectKey-AccountId-UserName) to store data to hive

(cherry picked from commit e0ace535d5f3af71eb13598d92524caf2c6d9bbf)
This commit is contained in:
dab246
2023-04-27 11:03:39 +07:00
committed by Dat Vu
parent 7d0a5729b2
commit 876cc368b0
107 changed files with 562 additions and 340 deletions
@@ -3,6 +3,7 @@ import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/user_name.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/repository/spam_report_repository.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/state/get_number_of_unread_spam_emails_state.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/state/get_spam_mailbox_cached_state.dart';
@@ -13,7 +14,7 @@ class GetSpamMailboxCachedInteractor {
GetSpamMailboxCachedInteractor(this._spamReportRepository);
Stream<Either<Failure, Success>> execute(AccountId accountId) async* {
Stream<Either<Failure, Success>> execute(AccountId accountId, UserName userName) async* {
try {
yield Right<Failure, Success>(GetSpamMailboxCachedLoading());
@@ -22,7 +23,7 @@ class GetSpamMailboxCachedInteractor {
final checkTimeCondition = timeLast.inHours > MailboxDashboardConstant.spamReportBannerDisplayTimeOut;
if (checkTimeCondition) {
final spamMailbox = await _spamReportRepository.getSpamMailboxCached(accountId);
final spamMailbox = await _spamReportRepository.getSpamMailboxCached(accountId, userName);
final countUnreadSpamMailbox = spamMailbox.unreadEmails?.value.value.toInt() ?? 0;
if (countUnreadSpamMailbox > 0) {
yield Right<Failure, Success>(GetSpamMailboxCachedSuccess(spamMailbox));
@@ -16,8 +16,8 @@ class RemoveEmailDraftsInteractor {
Stream<Either<Failure, Success>> execute(Session session, AccountId accountId, EmailId emailId) async* {
try {
final listState = await Future.wait([
_mailboxRepository.getMailboxState(accountId),
_emailRepository.getEmailState(accountId),
_mailboxRepository.getMailboxState(session, accountId),
_emailRepository.getEmailState(session, accountId),
], eagerError: true);
final currentMailboxState = listState.first;