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;
|
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 {
|
return Future.sync(() async {
|
||||||
|
if (needToReopen) {
|
||||||
|
await closeBox();
|
||||||
|
}
|
||||||
final boxItem = encryption
|
final boxItem = encryption
|
||||||
? await openBoxEncryption()
|
? await openBoxEncryption()
|
||||||
: await openBox();
|
: await openBox();
|
||||||
|
|||||||
@@ -223,8 +223,17 @@ class EmailRepositoryImpl extends EmailRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> storeSendingEmail(AccountId accountId, UserName userName, SendingEmail sendingEmail) {
|
Future<void> storeSendingEmail(
|
||||||
return emailDataSource[DataSourceType.hiveCache]!.storeSendingEmail(accountId, userName, sendingEmail);
|
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
|
@override
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ 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, bool isUpdateSendingEmail);
|
||||||
|
|
||||||
Future<void> deleteSendingEmail(AccountId accountId, UserName userName, String sendingId);
|
Future<void> deleteSendingEmail(AccountId accountId, UserName userName, String sendingId);
|
||||||
}
|
}
|
||||||
@@ -8,8 +8,9 @@ class StoreSendingEmailLoading extends UIState {}
|
|||||||
class StoreSendingEmailSuccess extends UIState {
|
class StoreSendingEmailSuccess extends UIState {
|
||||||
|
|
||||||
final SendingEmail sendingEmail;
|
final SendingEmail sendingEmail;
|
||||||
|
final bool isUpdateSendingEmail;
|
||||||
|
|
||||||
StoreSendingEmailSuccess(this.sendingEmail);
|
StoreSendingEmailSuccess(this.sendingEmail, this.isUpdateSendingEmail);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [sendingEmail];
|
List<Object?> get props => [sendingEmail];
|
||||||
|
|||||||
@@ -12,11 +12,16 @@ class StoreSendingEmailInteractor {
|
|||||||
|
|
||||||
StoreSendingEmailInteractor(this._emailRepository);
|
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 {
|
try {
|
||||||
yield Right<Failure, Success>(StoreSendingEmailLoading());
|
yield Right<Failure, Success>(StoreSendingEmailLoading());
|
||||||
await _emailRepository.storeSendingEmail(accountId, userName, sendingEmail);
|
await _emailRepository.storeSendingEmail(accountId, userName, sendingEmail, isUpdateSendingEmail);
|
||||||
yield Right<Failure, Success>(StoreSendingEmailSuccess(sendingEmail));
|
yield Right<Failure, Success>(StoreSendingEmailSuccess(sendingEmail, isUpdateSendingEmail));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
yield Left<Failure, Success>(StoreSendingEmailFailure(e));
|
yield Left<Failure, Success>(StoreSendingEmailFailure(e));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user