TW-4308 Add labels for several messages part 1#4430
TW-4308 Add labels for several messages part 1#4430tddang-linagora wants to merge 2 commits intomasterfrom
Conversation
WalkthroughThis PR introduces a bulk email labeling feature across the entire application stack. It adds the Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@lib/features/email/domain/usecases/labels/add_list_label_to_list_emails_interactor.dart`:
- Around line 33-40: The method in add_list_label_to_list_emails_interactor.dart
currently treats an empty emailIds list as success because 0 ==
result.emailIdsSuccess.length; add an early guard at the start of the use case
(before calling the repository) to check if emailIds.isEmpty and immediately
yield Left(AddListLabelsToListEmailsFailure(...)) with an appropriate
empty-selection error, so you never proceed to call the repository or return
AddListLabelsToListEmailsSuccess for a no-op; update any callers/tests expecting
the previous behavior accordingly and keep references to emailIds, result,
AddListLabelsToListEmailsSuccess and AddListLabelsToListEmailsFailure to locate
the change.
In `@lib/main/utils/toast_manager.dart`:
- Around line 327-330: The toast matching checks
AddListLabelsToListEmailsSuccess before its subclass
AddListLabelsToListEmailsHasSomeFailure, causing partial-failure cases to be
treated as full success; update the conditional order in toast_manager.dart so
that AddListLabelsToListEmailsHasSomeFailure is checked before
AddListLabelsToListEmailsSuccess (or otherwise explicitly check for the
partial-failure type first) and set message using
appLocalizations.addListLabelToListEmailHasSomeFailureMessage for the
HasSomeFailure branch.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 193b8500-00b9-482d-9513-e24a97f75c0a
📒 Files selected for processing (16)
lib/features/email/data/datasource/email_datasource.dartlib/features/email/data/datasource_impl/email_datasource_impl.dartlib/features/email/data/datasource_impl/email_hive_cache_datasource_impl.dartlib/features/email/data/datasource_impl/email_local_storage_datasource_impl.dartlib/features/email/data/datasource_impl/email_session_storage_datasource_impl.dartlib/features/email/data/network/email_api.dartlib/features/email/data/repository/email_repository_impl.dartlib/features/email/domain/repository/email_repository.dartlib/features/email/domain/state/labels/add_list_label_to_list_email_state.dartlib/features/email/domain/usecases/labels/add_list_label_to_list_emails_interactor.dartlib/features/thread/presentation/extensions/email_selection_action_type_extension.dartlib/features/thread/presentation/model/email_selection_action_type.dartlib/l10n/intl_messages.arblib/main/localizations/app_localizations.dartlib/main/utils/toast_manager.dartmodel/lib/extensions/list_email_id_extension.dart
| if (emailIds.length == result.emailIdsSuccess.length) { | ||
| yield Right(AddListLabelsToListEmailsSuccess( | ||
| result.emailIdsSuccess, | ||
| labelKeywords, | ||
| labelDisplays, | ||
| )); | ||
| } else if (result.emailIdsSuccess.isEmpty) { | ||
| yield Left(AddListLabelsToListEmailsFailure( |
There was a problem hiding this comment.
Handle empty selection before success branching.
emailIds.isEmpty currently resolves to success (0 == 0), which can show a misleading success for a no-op. Add an early guard before repository call/branching.
Proposed tweak
) async* {
try {
+ if (emailIds.isEmpty) {
+ yield Left(AddListLabelsToListEmailsFailure(
+ exception: EmailIdsSuccessIsEmptyException(),
+ labelDisplays: labelDisplays,
+ ));
+ return;
+ }
+
yield Right(AddingListLabelsToListEmails());
final result = await _emailRepository.addListLabelToListEmail(
session,
accountId,
emailIds,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@lib/features/email/domain/usecases/labels/add_list_label_to_list_emails_interactor.dart`
around lines 33 - 40, The method in
add_list_label_to_list_emails_interactor.dart currently treats an empty emailIds
list as success because 0 == result.emailIdsSuccess.length; add an early guard
at the start of the use case (before calling the repository) to check if
emailIds.isEmpty and immediately yield
Left(AddListLabelsToListEmailsFailure(...)) with an appropriate empty-selection
error, so you never proceed to call the repository or return
AddListLabelsToListEmailsSuccess for a no-op; update any callers/tests expecting
the previous behavior accordingly and keep references to emailIds, result,
AddListLabelsToListEmailsSuccess and AddListLabelsToListEmailsFailure to locate
the change.
| } else if (success is AddListLabelsToListEmailsSuccess) { | ||
| message = appLocalizations.addListLabelToListEmailSuccessfullyMessage; | ||
| } else if (success is AddListLabelsToListEmailsHasSomeFailure) { | ||
| message = appLocalizations.addListLabelToListEmailHasSomeFailureMessage; |
There was a problem hiding this comment.
Fix subclass check order to preserve partial-failure toast.
At Line 327, AddListLabelsToListEmailsSuccess is matched before AddListLabelsToListEmailsHasSomeFailure. Since the latter is a subclass of the former, partial failures are currently shown as full success.
🔧 Proposed fix
- } else if (success is AddListLabelsToListEmailsSuccess) {
- message = appLocalizations.addListLabelToListEmailSuccessfullyMessage;
- } else if (success is AddListLabelsToListEmailsHasSomeFailure) {
+ } else if (success is AddListLabelsToListEmailsHasSomeFailure) {
message = appLocalizations.addListLabelToListEmailHasSomeFailureMessage;
+ } else if (success is AddListLabelsToListEmailsSuccess) {
+ message = appLocalizations.addListLabelToListEmailSuccessfullyMessage;
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@lib/main/utils/toast_manager.dart` around lines 327 - 330, The toast matching
checks AddListLabelsToListEmailsSuccess before its subclass
AddListLabelsToListEmailsHasSomeFailure, causing partial-failure cases to be
treated as full success; update the conditional order in toast_manager.dart so
that AddListLabelsToListEmailsHasSomeFailure is checked before
AddListLabelsToListEmailsSuccess (or otherwise explicitly check for the
partial-failure type first) and set message using
appLocalizations.addListLabelToListEmailHasSomeFailureMessage for the
HasSomeFailure branch.
|
This PR has been deployed to https://linagora.github.io/tmail-flutter/4430. |
Data preparation only
Summary by CodeRabbit
Release Notes