TF-1865: Update sending email has been edited
(cherry picked from commit 1099d39a31ef0fa590f082a7c146734c819b1707)
This commit is contained in:
@@ -106,8 +106,11 @@ abstract class HiveCacheClient<T> {
|
||||
return tupleKey.parts.length >= 3 && tupleKey.parts[1] == accountId && tupleKey.parts[2] == userName;
|
||||
}
|
||||
|
||||
Future<void> updateItem(String key, T newObject) {
|
||||
Future<void> updateItem(String key, T newObject, {bool needToReopen = false}) {
|
||||
return Future.sync(() async {
|
||||
if (needToReopen) {
|
||||
await closeBox();
|
||||
}
|
||||
final boxItem = encryption
|
||||
? await openBoxEncryption()
|
||||
: await openBox();
|
||||
|
||||
@@ -223,8 +223,17 @@ class EmailRepositoryImpl extends EmailRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> storeSendingEmail(AccountId accountId, UserName userName, SendingEmail sendingEmail) {
|
||||
return emailDataSource[DataSourceType.hiveCache]!.storeSendingEmail(accountId, userName, sendingEmail);
|
||||
Future<void> storeSendingEmail(
|
||||
AccountId accountId,
|
||||
UserName userName,
|
||||
SendingEmail sendingEmail,
|
||||
bool isUpdateSendingEmail
|
||||
) async {
|
||||
if (isUpdateSendingEmail) {
|
||||
return await emailDataSource[DataSourceType.hiveCache]!.updateSendingEmail(accountId, userName, sendingEmail);
|
||||
} else {
|
||||
return await emailDataSource[DataSourceType.hiveCache]!.storeSendingEmail(accountId, userName, sendingEmail);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -102,7 +102,7 @@ abstract class EmailRepository {
|
||||
|
||||
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, bool isUpdateSendingEmail);
|
||||
|
||||
Future<void> deleteSendingEmail(AccountId accountId, UserName userName, String sendingId);
|
||||
}
|
||||
@@ -8,8 +8,9 @@ class StoreSendingEmailLoading extends UIState {}
|
||||
class StoreSendingEmailSuccess extends UIState {
|
||||
|
||||
final SendingEmail sendingEmail;
|
||||
final bool isUpdateSendingEmail;
|
||||
|
||||
StoreSendingEmailSuccess(this.sendingEmail);
|
||||
StoreSendingEmailSuccess(this.sendingEmail, this.isUpdateSendingEmail);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [sendingEmail];
|
||||
|
||||
@@ -12,11 +12,16 @@ class StoreSendingEmailInteractor {
|
||||
|
||||
StoreSendingEmailInteractor(this._emailRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId, UserName userName, SendingEmail sendingEmail) async* {
|
||||
Stream<Either<Failure, Success>> execute(
|
||||
AccountId accountId,
|
||||
UserName userName,
|
||||
SendingEmail sendingEmail,
|
||||
bool isUpdateSendingEmail
|
||||
) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(StoreSendingEmailLoading());
|
||||
await _emailRepository.storeSendingEmail(accountId, userName, sendingEmail);
|
||||
yield Right<Failure, Success>(StoreSendingEmailSuccess(sendingEmail));
|
||||
await _emailRepository.storeSendingEmail(accountId, userName, sendingEmail, isUpdateSendingEmail);
|
||||
yield Right<Failure, Success>(StoreSendingEmailSuccess(sendingEmail, isUpdateSendingEmail));
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(StoreSendingEmailFailure(e));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user