-
Notifications
You must be signed in to change notification settings - Fork 119
TW-4308 Add labels for several messages part 2 #4431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hoangdat
merged 4 commits into
master
from
feature/TW-4308-Add-labels-for-several-messages-part-2
Apr 15, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4195138
TF-4308 add ChooseLabelModal, delegate, and update label UI components
tddang-linagora dd48bc1
TF-4308 wire add-labels action across Thread, Search, and Dashboard
tddang-linagora 7a102e8
fixup! TF-4308 wire add-labels action across Thread, Search, and Dash…
dab246 a422e2e
fixup! fixup! TF-4308 wire add-labels action across Thread, Search, a…
dab246 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
lib/features/labels/domain/model/add_list_labels_to_list_emails_params.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import 'package:equatable/equatable.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/list_label_extension.dart'; | ||
| import 'package:labels/model/label.dart'; | ||
| import 'package:tmail_ui_user/features/email/domain/state/labels/add_list_label_to_list_email_state.dart'; | ||
|
|
||
| class AddListLabelsToListEmailsParams extends Equatable { | ||
| final List<Label> labels; | ||
| final List<EmailId> emailIds; | ||
| final OnSyncListLabelForListEmail onSync; | ||
|
|
||
| const AddListLabelsToListEmailsParams({ | ||
| required this.labels, | ||
| required this.emailIds, | ||
| required this.onSync, | ||
| }); | ||
|
|
||
| List<KeyWordIdentifier> get labelKeywords => labels.keywords; | ||
|
|
||
| List<String> get labelDisplays => labels.displayNameNotNullList; | ||
|
|
||
| @override | ||
| List<Object?> get props => [labels, emailIds, onSync]; | ||
| } |
93 changes: 93 additions & 0 deletions
93
lib/features/labels/presentation/delegates/add_list_label_to_list_emails_delegate.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import 'package:core/presentation/resources/image_paths.dart'; | ||
| import 'package:core/presentation/state/failure.dart'; | ||
| import 'package:core/presentation/state/success.dart'; | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:model/email/presentation_email.dart'; | ||
| import 'package:model/extensions/list_presentation_email_extension.dart'; | ||
| import 'package:tmail_ui_user/features/base/base_controller.dart'; | ||
| import 'package:tmail_ui_user/features/email/domain/state/labels/add_list_label_to_list_email_state.dart'; | ||
| import 'package:tmail_ui_user/features/email/domain/usecases/labels/add_list_label_to_list_emails_interactor.dart'; | ||
| import 'package:tmail_ui_user/features/home/data/exceptions/session_exceptions.dart'; | ||
| import 'package:tmail_ui_user/features/labels/domain/exceptions/label_exceptions.dart'; | ||
| import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart'; | ||
| import 'package:tmail_ui_user/features/labels/domain/model/add_list_labels_to_list_emails_params.dart'; | ||
| import 'package:tmail_ui_user/features/labels/presentation/label_controller.dart'; | ||
| import 'package:tmail_ui_user/features/labels/presentation/widgets/choose_label_modal.dart'; | ||
| import 'package:tmail_ui_user/main/routes/dialog_router.dart'; | ||
|
|
||
| class AddListLabelToListEmailsDelegate extends BaseController { | ||
| final LabelController _labelController; | ||
| final AddListLabelToListEmailsInteractor _interactor; | ||
|
|
||
| AddListLabelToListEmailsDelegate(this._labelController, this._interactor); | ||
|
|
||
| Future<void> openChooseLabelModal({ | ||
| required List<PresentationEmail> selectedEmails, | ||
| required ImagePaths imagePaths, | ||
| required VoidCallback onCancel, | ||
| required OnSyncListLabelForListEmail onSync, | ||
| }) async { | ||
| if (_labelController.labels.isEmpty) return; | ||
|
|
||
| await DialogRouter().openDialogModal( | ||
| child: ChooseLabelModal( | ||
| labels: _labelController.labels, | ||
| onLabelAsToEmailsAction: (labels) { | ||
| onCancel(); | ||
| _addLabels( | ||
| AddListLabelsToListEmailsParams( | ||
| labels: labels, | ||
| emailIds: selectedEmails.listEmailIds, | ||
| onSync: onSync, | ||
| ), | ||
| ); | ||
| }, | ||
| imagePaths: imagePaths, | ||
| ), | ||
| dialogLabel: 'choose-label-modal', | ||
| ); | ||
| } | ||
|
|
||
| void _addLabels( | ||
| AddListLabelsToListEmailsParams params, | ||
| ) { | ||
| final session = _labelController.session; | ||
| final accountId = _labelController.accountId; | ||
|
|
||
| final exception = _validateParams(params.labelKeywords); | ||
| if (exception != null) { | ||
| emitFailure( | ||
| controller: this, | ||
| failure: AddListLabelsToListEmailsFailure( | ||
| exception: exception, | ||
| labelDisplays: params.labelDisplays, | ||
| ), | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| consumeState(_interactor.execute(session!, accountId!, params)); | ||
| } | ||
|
|
||
| Exception? _validateParams(List<KeyWordIdentifier> keywords) { | ||
| if (_labelController.session == null) return NotFoundSessionException(); | ||
| if (_labelController.accountId == null) return NotFoundAccountIdException(); | ||
| if (keywords.isEmpty) return const LabelKeywordIsNull(); | ||
| return null; | ||
| } | ||
|
|
||
| @override | ||
| void handleSuccessViewState(Success success) { | ||
| if (success is AddListLabelsToListEmailsSuccess) { | ||
|
hoangdat marked this conversation as resolved.
|
||
| toastManager.showMessageSuccess(success); | ||
| success.onSync?.call(success.emailIds, success.labelKeywords, shouldRemove: false); | ||
| } | ||
|
dab246 marked this conversation as resolved.
|
||
| } | ||
|
|
||
| @override | ||
| void handleFailureViewState(Failure failure) { | ||
| if (failure is AddListLabelsToListEmailsFailure) { | ||
| toastManager.showMessageFailure(failure); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.