TF-4195 Fix comments of coderabbit
This commit is contained in:
@@ -206,6 +206,7 @@ abstract class EmailDataSource {
|
||||
Future<String> generateEntireMessageAsDocument(ViewEntireMessageRequest entireMessageRequest);
|
||||
|
||||
Future<void> addLabelToEmail(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
EmailId emailId,
|
||||
KeyWordIdentifier labelKeyword,
|
||||
|
||||
@@ -556,12 +556,18 @@ class EmailDataSourceImpl extends EmailDataSource {
|
||||
|
||||
@override
|
||||
Future<void> addLabelToEmail(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
EmailId emailId,
|
||||
KeyWordIdentifier labelKeyword,
|
||||
) {
|
||||
return Future.sync(() async {
|
||||
return await emailAPI.addLabelToEmail(accountId, emailId, labelKeyword);
|
||||
return await emailAPI.addLabelToEmail(
|
||||
session,
|
||||
accountId,
|
||||
emailId,
|
||||
labelKeyword,
|
||||
);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
}
|
||||
@@ -577,7 +577,7 @@ class EmailHiveCacheDataSourceImpl extends EmailDataSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> addLabelToEmail(AccountId accountId, EmailId emailId, KeyWordIdentifier labelKeyword) {
|
||||
Future<void> addLabelToEmail(Session session, AccountId accountId, EmailId emailId, KeyWordIdentifier labelKeyword) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
@@ -353,7 +353,7 @@ class EmailLocalStorageDataSourceImpl extends EmailDataSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> addLabelToEmail(AccountId accountId, EmailId emailId, KeyWordIdentifier labelKeyword) {
|
||||
Future<void> addLabelToEmail(Session session, AccountId accountId, EmailId emailId, KeyWordIdentifier labelKeyword) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
@@ -267,7 +267,7 @@ class EmailSessionStorageDatasourceImpl extends EmailDataSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> addLabelToEmail(AccountId accountId, EmailId emailId, KeyWordIdentifier labelKeyword) {
|
||||
Future<void> addLabelToEmail(Session session, AccountId accountId, EmailId emailId, KeyWordIdentifier labelKeyword) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
@@ -938,6 +938,7 @@ class EmailAPI with HandleSetErrorMixin, MailAPIMixin {
|
||||
}
|
||||
|
||||
Future<void> addLabelToEmail(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
EmailId emailId,
|
||||
KeyWordIdentifier labelKeyword,
|
||||
@@ -948,8 +949,9 @@ class EmailAPI with HandleSetErrorMixin, MailAPIMixin {
|
||||
final builder = JmapRequestBuilder(_httpClient, ProcessingInvocation());
|
||||
final invocation = builder.invocation(method);
|
||||
|
||||
final result =
|
||||
await (builder..usings(method.requiredCapabilities)).build().execute();
|
||||
final capabilities = method.requiredCapabilities
|
||||
.toCapabilitiesSupportTeamMailboxes(session, accountId);
|
||||
final result = await (builder..usings(capabilities)).build().execute();
|
||||
|
||||
final response = result.parse<SetEmailResponse>(
|
||||
invocation.methodCallId,
|
||||
|
||||
@@ -483,11 +483,13 @@ class EmailRepositoryImpl extends EmailRepository {
|
||||
|
||||
@override
|
||||
Future<void> addLabelToEmail(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
EmailId emailId,
|
||||
KeyWordIdentifier labelKeyword,
|
||||
) {
|
||||
return emailDataSource[DataSourceType.network]!.addLabelToEmail(
|
||||
session,
|
||||
accountId,
|
||||
emailId,
|
||||
labelKeyword,
|
||||
|
||||
@@ -163,6 +163,7 @@ abstract class EmailRepository {
|
||||
Future<String> generateEntireMessageAsDocument(ViewEntireMessageRequest entireMessageRequest);
|
||||
|
||||
Future<void> addLabelToEmail(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
EmailId emailId,
|
||||
KeyWordIdentifier labelKeyword,
|
||||
|
||||
@@ -2,6 +2,7 @@ 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';
|
||||
@@ -13,6 +14,7 @@ class AddALabelToAnEmailInteractor {
|
||||
AddALabelToAnEmailInteractor(this._emailRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
EmailId emailId,
|
||||
KeyWordIdentifier labelKeyword,
|
||||
@@ -21,6 +23,7 @@ class AddALabelToAnEmailInteractor {
|
||||
try {
|
||||
yield Right(AddingALabelToAnEmail());
|
||||
await _emailRepository.addLabelToEmail(
|
||||
session,
|
||||
accountId,
|
||||
emailId,
|
||||
labelKeyword,
|
||||
|
||||
@@ -118,7 +118,7 @@ class EmailInteractorBindings extends InteractorsBindings {
|
||||
Get.find<EmailRepository>(),
|
||||
));
|
||||
}
|
||||
Get.lazyPut(
|
||||
Get.lazyPut<AddALabelToAnEmailInteractor>(
|
||||
() => AddALabelToAnEmailInteractor(Get.find<EmailRepository>()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -221,7 +221,6 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
|
||||
@override
|
||||
void handleSuccessViewState(Success success) {
|
||||
log('SingleEmailController::handleSuccessViewState(): $success');
|
||||
if (success is GetEmailContentSuccess) {
|
||||
_getEmailContentSuccess(success);
|
||||
} else if (success is GetEmailContentFromCacheSuccess) {
|
||||
@@ -255,7 +254,6 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
|
||||
@override
|
||||
void handleFailureViewState(Failure failure) {
|
||||
logError('SingleEmailController::handleFailureViewState(): $failure');
|
||||
if (failure is MarkAsEmailReadFailure) {
|
||||
_handleMarkAsEmailReadFailure(failure);
|
||||
} else if (failure is ParseCalendarEventFailure) {
|
||||
@@ -899,6 +897,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
pressEmailAction(actionType, presentationEmail);
|
||||
break;
|
||||
case EmailActionType.labelAs:
|
||||
if (!isLabelFeatureEnabled) return;
|
||||
openAddLabelToEmailDialogModal(presentationEmail);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -596,12 +596,13 @@ class EmailView extends GetWidget<SingleEmailController> {
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
final dialogRouter = DialogRouter();
|
||||
bool isOverlayEnabled = controller.mailboxDashBoardController.isDisplayedOverlayViewOnIFrame ||
|
||||
MessageDialogActionManager().isDialogOpened ||
|
||||
EmailActionReactor.isDialogOpened ||
|
||||
ColorDialogPicker().isOpened.isTrue ||
|
||||
DialogRouter().isRuleFilterDialogOpened.isTrue ||
|
||||
DialogRouter().isDialogOpened;
|
||||
dialogRouter.isRuleFilterDialogOpened.isTrue ||
|
||||
dialogRouter.isDialogOpened;
|
||||
|
||||
if (isOverlayEnabled) {
|
||||
return Positioned.fill(
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:model/extensions/email_extension.dart';
|
||||
import 'package:model/extensions/list_email_header_extension.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/model/smime_signature_status.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/utils/smime_signature_constant.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/extensions/map_keywords_extension.dart';
|
||||
|
||||
extension EmailExtension on Email {
|
||||
|
||||
@@ -39,7 +41,7 @@ extension EmailExtension on Email {
|
||||
|
||||
bool fromMe(String ownEmailAddress) {
|
||||
return from?.any(
|
||||
(emailAdress) => emailAdress.email == ownEmailAddress
|
||||
(emailAddress) => emailAddress.email == ownEmailAddress
|
||||
) == true;
|
||||
}
|
||||
|
||||
@@ -50,7 +52,15 @@ extension EmailExtension on Email {
|
||||
...bcc ?? {},
|
||||
};
|
||||
return recipients.any(
|
||||
(emailAdress) => emailAdress.email == ownEmailAddress
|
||||
(emailAddress) => emailAddress.email == ownEmailAddress
|
||||
) == true;
|
||||
}
|
||||
|
||||
Email toggleKeyword(KeyWordIdentifier keyword, bool remove) {
|
||||
return copyWith(
|
||||
keywords: remove
|
||||
? keywords.withoutKeyword(keyword)
|
||||
: keywords.withKeyword(keyword),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,20 @@
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
||||
import 'package:model/extensions/email_extension.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/extensions/email_extension.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/model/email_loaded.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/extensions/map_keywords_extension.dart';
|
||||
|
||||
extension EmailLoadedExtension on EmailLoaded {
|
||||
EmailLoaded addEmailKeyword({
|
||||
EmailLoaded toggleEmailKeyword({
|
||||
required EmailId emailId,
|
||||
required KeyWordIdentifier keyword,
|
||||
required bool remove,
|
||||
}) {
|
||||
if (emailCurrent == null || emailCurrent?.id != emailId) {
|
||||
final current = emailCurrent;
|
||||
if (current == null || current.id != emailId) {
|
||||
return this;
|
||||
}
|
||||
final newKeyword = emailCurrent?.keywords?.withKeyword(keyword);
|
||||
final updatedEmail = emailCurrent?.copyWith(keywords: newKeyword);
|
||||
return copyWith(emailCurrent: updatedEmail);
|
||||
}
|
||||
|
||||
EmailLoaded removeEmailKeyword({
|
||||
required EmailId emailId,
|
||||
required KeyWordIdentifier keyword,
|
||||
}) {
|
||||
if (emailCurrent == null || emailCurrent?.id != emailId) {
|
||||
return this;
|
||||
}
|
||||
final newKeyword = emailCurrent?.keywords?.withoutKeyword(keyword);
|
||||
final updatedEmail = emailCurrent?.copyWith(keywords: newKeyword);
|
||||
return copyWith(emailCurrent: updatedEmail);
|
||||
return copyWith(
|
||||
emailCurrent: current.toggleKeyword(keyword, remove),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:core/utils/platform_info.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:get/get.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:labels/extensions/label_extension.dart';
|
||||
@@ -29,8 +30,10 @@ extension HandleLabelForEmailExtension on SingleEmailController {
|
||||
void toggleLabelToEmail(EmailId emailId, Label label, bool isSelected) {
|
||||
if (isSelected) {
|
||||
final accountId = mailboxDashBoardController.accountId.value;
|
||||
final session = mailboxDashBoardController.sessionCurrent;
|
||||
|
||||
_addALabelToAnEmail(
|
||||
session: session,
|
||||
accountId: accountId,
|
||||
emailId: emailId,
|
||||
label: label,
|
||||
@@ -39,12 +42,25 @@ extension HandleLabelForEmailExtension on SingleEmailController {
|
||||
}
|
||||
|
||||
void _addALabelToAnEmail({
|
||||
required Session? session,
|
||||
required AccountId? accountId,
|
||||
required Label label,
|
||||
required EmailId emailId,
|
||||
}) {
|
||||
final labelDisplay = label.safeDisplayName;
|
||||
|
||||
if (session == null) {
|
||||
consumeState(
|
||||
Stream.value(
|
||||
Left(AddALabelToAnEmailFailure(
|
||||
exception: NotFoundSessionException(),
|
||||
labelDisplay: labelDisplay,
|
||||
)),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (accountId == null) {
|
||||
consumeState(
|
||||
Stream.value(
|
||||
@@ -71,6 +87,7 @@ extension HandleLabelForEmailExtension on SingleEmailController {
|
||||
}
|
||||
|
||||
consumeState(addALabelToAnEmailInteractor.execute(
|
||||
session,
|
||||
accountId,
|
||||
emailId,
|
||||
labelKeyword,
|
||||
@@ -117,24 +134,27 @@ extension HandleLabelForEmailExtension on SingleEmailController {
|
||||
final controller = threadDetailController;
|
||||
if (controller != null) {
|
||||
controller.emailIdsPresentation.value =
|
||||
controller.emailIdsPresentation.addEmailKeywordById(
|
||||
controller.emailIdsPresentation.toggleEmailKeywordById(
|
||||
emailId: emailId,
|
||||
keyword: labelKeyword,
|
||||
remove: false,
|
||||
);
|
||||
|
||||
controller.emailsInThreadDetailInfo.value =
|
||||
controller.emailsInThreadDetailInfo.addEmailKeywordById(
|
||||
controller.emailsInThreadDetailInfo.toggleEmailKeywordById(
|
||||
emailId: emailId,
|
||||
keyword: labelKeyword,
|
||||
remove: false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final emailLoaded = currentEmailLoaded.value;
|
||||
if (emailLoaded != null && emailLoaded.emailCurrent?.id == emailId) {
|
||||
currentEmailLoaded.value = emailLoaded.addEmailKeyword(
|
||||
currentEmailLoaded.value = emailLoaded.toggleEmailKeyword(
|
||||
emailId: emailId,
|
||||
keyword: labelKeyword,
|
||||
remove: false,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -148,6 +168,7 @@ extension HandleLabelForEmailExtension on SingleEmailController {
|
||||
}
|
||||
|
||||
Future<void> openAddLabelToEmailDialogModal(PresentationEmail email) async {
|
||||
if (!isLabelFeatureEnabled) return;
|
||||
final labels = mailboxDashBoardController.labelController.labels;
|
||||
final emailLabels = email.getLabelList(labels);
|
||||
final emailId = email.id;
|
||||
|
||||
@@ -170,15 +170,13 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
.toList();
|
||||
}
|
||||
|
||||
PresentationEmail addKeyword(KeyWordIdentifier keyword) {
|
||||
PresentationEmail toggleKeyword(KeyWordIdentifier keyword, bool remove) {
|
||||
return copyWith(
|
||||
keywords: keywords.withKeyword(keyword),
|
||||
);
|
||||
}
|
||||
|
||||
PresentationEmail removeKeyword(KeyWordIdentifier keyword) {
|
||||
return copyWith(
|
||||
keywords: keywords.withoutKeyword(keyword),
|
||||
);
|
||||
keywords: remove
|
||||
? keywords.withoutKeyword(keyword)
|
||||
: keywords.withKeyword(keyword),
|
||||
)
|
||||
..searchSnippetSubject = searchSnippetSubject
|
||||
..searchSnippetPreview = searchSnippetPreview;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user