TF-1842: Create deleteSendingEmail in domain layer
(cherry picked from commit b66931aa1b6cabb7ac32d9457d6d4ed69d3ea42d)
This commit is contained in:
@@ -260,4 +260,12 @@ class EmailHiveCacheDataSourceImpl extends EmailDataSource {
|
|||||||
return sendingEmailsCache.toSendingEmails();
|
return sendingEmailsCache.toSendingEmails();
|
||||||
}).catchError(_exceptionThrower.throwException);
|
}).catchError(_exceptionThrower.throwException);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deleteSendingEmail(AccountId accountId, UserName userName, EmailId emailId) {
|
||||||
|
return Future.sync(() async {
|
||||||
|
return await _sendingEmailCacheManager.deleteSendingEmail(accountId, userName, emailId.id.value);
|
||||||
|
}).catchError(_exceptionThrower.throwException);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -103,4 +103,6 @@ abstract class EmailRepository {
|
|||||||
Future<DetailedEmail?> getOpenedEmail(Session session, AccountId accountId, EmailId emailId);
|
Future<DetailedEmail?> getOpenedEmail(Session session, AccountId accountId, EmailId emailId);
|
||||||
|
|
||||||
Future<void> storeSendingEmail(AccountId accountId, UserName userName, SendingEmail sendingEmail);
|
Future<void> storeSendingEmail(AccountId accountId, UserName userName, SendingEmail sendingEmail);
|
||||||
|
|
||||||
|
Future<void> deleteSendingEmail(AccountId accountId, UserName userName, EmailId emailId);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import 'package:core/presentation/state/failure.dart';
|
||||||
|
import 'package:core/presentation/state/success.dart';
|
||||||
|
|
||||||
|
class DeleteSendingEmailLoading extends UIState {}
|
||||||
|
|
||||||
|
class DeleteSendingEmailSuccess extends UIState {
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [];
|
||||||
|
}
|
||||||
|
|
||||||
|
class DeleteSendingEmailFailure extends FeatureFailure {
|
||||||
|
DeleteSendingEmailFailure(dynamic exception) : super(exception: exception);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [exception];
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
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:jmap_dart_client/jmap/mail/email/email.dart';
|
||||||
|
import 'package:tmail_ui_user/features/email/domain/repository/email_repository.dart';
|
||||||
|
import 'package:tmail_ui_user/features/email/domain/state/delete_sending_email_state.dart';
|
||||||
|
|
||||||
|
class DeleteSendingEmailInteractor {
|
||||||
|
final EmailRepository _emailRepository;
|
||||||
|
|
||||||
|
DeleteSendingEmailInteractor(this._emailRepository);
|
||||||
|
|
||||||
|
Stream<Either<Failure, Success>> execute(AccountId accountId, UserName userName, EmailId emailId) async* {
|
||||||
|
try {
|
||||||
|
yield Right<Failure, Success>(DeleteSendingEmailLoading());
|
||||||
|
await _emailRepository.deleteSendingEmail(accountId, userName, emailId);
|
||||||
|
yield Right<Failure, Success>(DeleteSendingEmailSuccess());
|
||||||
|
} catch (e) {
|
||||||
|
yield Left<Failure, Success>(DeleteSendingEmailFailure(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,4 +30,14 @@ class SendingEmailCacheManager {
|
|||||||
sendingEmailsCache.sortByLatestTime();
|
sendingEmailsCache.sortByLatestTime();
|
||||||
return sendingEmailsCache;
|
return sendingEmailsCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> deleteSendingEmail(
|
||||||
|
AccountId accountId,
|
||||||
|
UserName userName,
|
||||||
|
String sendingEmailId
|
||||||
|
) {
|
||||||
|
final keyCache = TupleKey(sendingEmailId, accountId.asString, userName.value).encodeKey;
|
||||||
|
log('SendingEmailCacheManager::deleteSendingEmail():keyCache: $keyCache');
|
||||||
|
return _hiveCacheClient.deleteItem(keyCache);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user