TF-4236 Implement remove a label from an thread
This commit is contained in:
@@ -182,4 +182,11 @@ abstract class EmailRepository {
|
||||
EmailId emailId,
|
||||
KeyWordIdentifier labelKeyword,
|
||||
);
|
||||
|
||||
Future<void> removeLabelFromThread(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
List<EmailId> emailIds,
|
||||
KeyWordIdentifier labelKeyword,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
||||
|
||||
class RemovingALabelFromAThread extends LoadingState {}
|
||||
|
||||
class RemoveALabelFromAThreadSuccess extends UIState {
|
||||
final List<EmailId> emailIds;
|
||||
final KeyWordIdentifier labelKeyword;
|
||||
final String labelDisplay;
|
||||
|
||||
RemoveALabelFromAThreadSuccess(
|
||||
this.emailIds,
|
||||
this.labelKeyword,
|
||||
this.labelDisplay,
|
||||
);
|
||||
|
||||
@override
|
||||
List<Object> get props => [emailIds, labelKeyword, labelDisplay];
|
||||
}
|
||||
|
||||
class RemoveALabelFromAThreadFailure extends FeatureFailure {
|
||||
final String labelDisplay;
|
||||
|
||||
RemoveALabelFromAThreadFailure({
|
||||
dynamic exception,
|
||||
required this.labelDisplay,
|
||||
}) : super(exception: exception);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [...super.props, labelDisplay];
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
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/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/repository/email_repository.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/labels/remove_a_label_from_an_thread_state.dart';
|
||||
|
||||
class RemoveALabelFromAThreadInteractor {
|
||||
final EmailRepository _emailRepository;
|
||||
|
||||
RemoveALabelFromAThreadInteractor(this._emailRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
List<EmailId> emailIds,
|
||||
KeyWordIdentifier labelKeyword,
|
||||
String labelDisplay,
|
||||
) async* {
|
||||
try {
|
||||
yield Right(RemovingALabelFromAThread());
|
||||
await _emailRepository.removeLabelFromThread(
|
||||
session,
|
||||
accountId,
|
||||
emailIds,
|
||||
labelKeyword,
|
||||
);
|
||||
yield Right(RemoveALabelFromAThreadSuccess(
|
||||
emailIds,
|
||||
labelKeyword,
|
||||
labelDisplay,
|
||||
));
|
||||
} catch (e) {
|
||||
yield Left(RemoveALabelFromAThreadFailure(
|
||||
exception: e,
|
||||
labelDisplay: labelDisplay,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user