TF-4236 Apply BatchSetEmailProcessingMixin for some method use SetEmailMethod
This commit is contained in:
@@ -22,4 +22,6 @@ class NotParsableBlobIdToEmailException implements Exception {
|
||||
final List<Id>? ids;
|
||||
|
||||
NotParsableBlobIdToEmailException({this.ids});
|
||||
}
|
||||
}
|
||||
|
||||
class EmailIdListIsEmptyException implements Exception {}
|
||||
@@ -169,7 +169,10 @@ abstract class EmailRepository {
|
||||
KeyWordIdentifier labelKeyword,
|
||||
);
|
||||
|
||||
Future<void> addLabelToThread(
|
||||
Future<({
|
||||
List<EmailId> emailIdsSuccess,
|
||||
Map<Id, SetError> mapErrors,
|
||||
})> addLabelToThread(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
List<EmailId> emailIds,
|
||||
@@ -183,7 +186,10 @@ abstract class EmailRepository {
|
||||
KeyWordIdentifier labelKeyword,
|
||||
);
|
||||
|
||||
Future<void> removeLabelFromThread(
|
||||
Future<({
|
||||
List<EmailId> emailIdsSuccess,
|
||||
Map<Id, SetError> mapErrors,
|
||||
})> removeLabelFromThread(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
List<EmailId> emailIds,
|
||||
|
||||
@@ -16,6 +16,14 @@ class AddALabelToAThreadSuccess extends UIState {
|
||||
List<Object> get props => [emailIds, labelKeyword, labelDisplay];
|
||||
}
|
||||
|
||||
class AddALabelToAThreadHasSomeFailure extends AddALabelToAThreadSuccess {
|
||||
AddALabelToAThreadHasSomeFailure(
|
||||
super.emailIds,
|
||||
super.labelKeyword,
|
||||
super.labelDisplay,
|
||||
);
|
||||
}
|
||||
|
||||
class AddALabelToAThreadFailure extends FeatureFailure {
|
||||
final String labelDisplay;
|
||||
|
||||
|
||||
@@ -20,6 +20,15 @@ class RemoveALabelFromAThreadSuccess extends UIState {
|
||||
List<Object> get props => [emailIds, labelKeyword, labelDisplay];
|
||||
}
|
||||
|
||||
class RemoveALabelFromAThreadHasSomeFailure
|
||||
extends RemoveALabelFromAThreadSuccess {
|
||||
RemoveALabelFromAThreadHasSomeFailure(
|
||||
super.emailIds,
|
||||
super.labelKeyword,
|
||||
super.labelDisplay,
|
||||
);
|
||||
}
|
||||
|
||||
class RemoveALabelFromAThreadFailure extends FeatureFailure {
|
||||
final String labelDisplay;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/exceptions/email_exceptions.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/repository/email_repository.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/add_a_label_to_a_thread_state.dart';
|
||||
|
||||
@@ -22,17 +23,30 @@ class AddALabelToAThreadInteractor {
|
||||
) async* {
|
||||
try {
|
||||
yield Right(AddingALabelToAThread());
|
||||
await _emailRepository.addLabelToThread(
|
||||
final result = await _emailRepository.addLabelToThread(
|
||||
session,
|
||||
accountId,
|
||||
emailIds,
|
||||
labelKeyword,
|
||||
);
|
||||
yield Right(AddALabelToAThreadSuccess(
|
||||
emailIds,
|
||||
labelKeyword,
|
||||
labelDisplay,
|
||||
));
|
||||
if (emailIds.length == result.emailIdsSuccess.length) {
|
||||
yield Right(AddALabelToAThreadSuccess(
|
||||
result.emailIdsSuccess,
|
||||
labelKeyword,
|
||||
labelDisplay,
|
||||
));
|
||||
} else if (result.emailIdsSuccess.isEmpty) {
|
||||
yield Left(AddALabelToAThreadFailure(
|
||||
exception: EmailIdListIsEmptyException(),
|
||||
labelDisplay: labelDisplay,
|
||||
));
|
||||
} else {
|
||||
yield Right(AddALabelToAThreadHasSomeFailure(
|
||||
result.emailIdsSuccess,
|
||||
labelKeyword,
|
||||
labelDisplay,
|
||||
));
|
||||
}
|
||||
} catch (e) {
|
||||
yield Left(AddALabelToAThreadFailure(
|
||||
exception: e,
|
||||
|
||||
+20
-6
@@ -5,6 +5,7 @@ import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/exceptions/email_exceptions.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/repository/email_repository.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/labels/remove_a_label_from_a_thread_state.dart';
|
||||
|
||||
@@ -22,17 +23,30 @@ class RemoveALabelFromAThreadInteractor {
|
||||
) async* {
|
||||
try {
|
||||
yield Right(RemovingALabelFromAThread());
|
||||
await _emailRepository.removeLabelFromThread(
|
||||
final result = await _emailRepository.removeLabelFromThread(
|
||||
session,
|
||||
accountId,
|
||||
emailIds,
|
||||
labelKeyword,
|
||||
);
|
||||
yield Right(RemoveALabelFromAThreadSuccess(
|
||||
emailIds,
|
||||
labelKeyword,
|
||||
labelDisplay,
|
||||
));
|
||||
if (emailIds.length == result.emailIdsSuccess.length) {
|
||||
yield Right(RemoveALabelFromAThreadSuccess(
|
||||
result.emailIdsSuccess,
|
||||
labelKeyword,
|
||||
labelDisplay,
|
||||
));
|
||||
} else if (result.emailIdsSuccess.isEmpty) {
|
||||
yield Left(RemoveALabelFromAThreadFailure(
|
||||
exception: EmailIdListIsEmptyException(),
|
||||
labelDisplay: labelDisplay,
|
||||
));
|
||||
} else {
|
||||
yield Right(RemoveALabelFromAThreadHasSomeFailure(
|
||||
result.emailIdsSuccess,
|
||||
labelKeyword,
|
||||
labelDisplay,
|
||||
));
|
||||
}
|
||||
} catch (e) {
|
||||
yield Left(RemoveALabelFromAThreadFailure(
|
||||
exception: e,
|
||||
|
||||
Reference in New Issue
Block a user