-
Notifications
You must be signed in to change notification settings - Fork 118
TF-4190 Performance issue to edit thread favorites #4191
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
Open
dab246
wants to merge
6
commits into
master
Choose a base branch
from
bugfix/tf-4190-performance-issue-to-edit-thread-favorites
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e520b87
TF-4190 Performance issue to edit thread favorites
dab246 2c10db2
fixup! TF-4190 Performance issue to edit thread favorites
dab246 d36977e
TF-4190 Add unit test for MapKeywordsExtension
dab246 eb1ccf3
fixup! TF-4190 Add unit test for MapKeywordsExtension
dab246 4f7c786
fixup! fixup! TF-4190 Add unit test for MapKeywordsExtension
dab246 35f07f9
fixup! fixup! fixup! TF-4190 Add unit test for MapKeywordsExtension
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
19 changes: 19 additions & 0 deletions
19
lib/features/email/presentation/extensions/email_loaded_extension.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,19 @@ | ||
| 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/presentation/extensions/email_extension.dart'; | ||
| import 'package:tmail_ui_user/features/email/presentation/model/email_loaded.dart'; | ||
|
|
||
| extension EmailLoadedExtension on EmailLoaded { | ||
| EmailLoaded toggleEmailKeyword({ | ||
| required EmailId emailId, | ||
| required KeyWordIdentifier keyword, | ||
| required bool isRemoved, | ||
| }) { | ||
| if (emailCurrent == null || emailCurrent?.id != emailId) { | ||
| return this; | ||
| } | ||
| return copyWith( | ||
| emailCurrent: emailCurrent?.toggleKeyword(keyword, isRemoved), | ||
| ); | ||
| } | ||
| } |
81 changes: 81 additions & 0 deletions
81
lib/features/email/presentation/extensions/handle_email_action_extension.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,81 @@ | ||
| import 'package:core/utils/platform_info.dart'; | ||
| import 'package:jmap_dart_client/jmap/mail/email/email.dart'; | ||
| import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart'; | ||
| import 'package:model/email/mark_star_action.dart'; | ||
| import 'package:tmail_ui_user/features/email/domain/state/mark_as_email_star_state.dart'; | ||
| import 'package:tmail_ui_user/features/email/presentation/controller/single_email_controller.dart'; | ||
| import 'package:tmail_ui_user/features/email/presentation/extensions/email_loaded_extension.dart'; | ||
| import 'package:tmail_ui_user/features/email/presentation/extensions/presentation_email_extension.dart'; | ||
| import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/update_current_emails_flags_extension.dart'; | ||
| import 'package:tmail_ui_user/features/thread_detail/domain/extensions/list_email_in_thread_detail_info_extension.dart'; | ||
| import 'package:tmail_ui_user/features/thread_detail/domain/extensions/presentation_email_map_extension.dart'; | ||
|
|
||
| extension HandleEmailActionExtension on SingleEmailController { | ||
| void markAsEmailStarSuccess(MarkAsStarEmailSuccess success) { | ||
| toastManager.showMessageSuccess(success); | ||
|
|
||
| _autoSyncStarToSelectedEmailOnMemory( | ||
| markStarAction: success.markStarAction, | ||
| emailId: success.emailId, | ||
| starKeyword: KeyWordIdentifier.emailFlagged, | ||
| ); | ||
| } | ||
|
|
||
| void _autoSyncStarToSelectedEmailOnMemory({ | ||
| required MarkStarAction markStarAction, | ||
| required EmailId emailId, | ||
| required KeyWordIdentifier starKeyword, | ||
| }) { | ||
| _updateStarInEmailOnMemory( | ||
| emailId: emailId, | ||
| starKeyword: starKeyword, | ||
| markStarAction: markStarAction, | ||
| isMobileThreadDisabled: PlatformInfo.isMobile && !isThreadDetailEnabled, | ||
| ); | ||
| } | ||
|
|
||
| void _updateStarInEmailOnMemory({ | ||
| required MarkStarAction markStarAction, | ||
| required EmailId emailId, | ||
| required KeyWordIdentifier starKeyword, | ||
| required bool isMobileThreadDisabled, | ||
| }) { | ||
| final isRemoved = markStarAction == MarkStarAction.unMarkStar; | ||
|
|
||
| if (isMobileThreadDisabled) { | ||
| final selectedEmail = mailboxDashBoardController.selectedEmail.value; | ||
| if (selectedEmail?.id == emailId) { | ||
| mailboxDashBoardController.selectedEmail.value = | ||
| selectedEmail?.toggleKeyword(starKeyword, isRemoved); | ||
| } | ||
| } else { | ||
| final controller = threadDetailController; | ||
| if (controller != null) { | ||
| controller.emailIdsPresentation.value = | ||
| controller.emailIdsPresentation.toggleEmailKeywordById( | ||
| emailId: emailId, | ||
| keyword: starKeyword, | ||
| isRemoved: isRemoved, | ||
| ); | ||
|
|
||
| controller.emailsInThreadDetailInfo.value = | ||
| controller.emailsInThreadDetailInfo.toggleEmailKeywordById( | ||
| emailId: emailId, keyword: starKeyword, isRemoved: isRemoved); | ||
| } | ||
| } | ||
|
|
||
| final emailLoaded = currentEmailLoaded.value; | ||
| if (emailLoaded != null && emailLoaded.emailCurrent?.id == emailId) { | ||
| currentEmailLoaded.value = emailLoaded.toggleEmailKeyword( | ||
| emailId: emailId, | ||
| keyword: starKeyword, | ||
| isRemoved: isRemoved, | ||
| ); | ||
| } | ||
|
|
||
| mailboxDashBoardController.updateEmailFlagByEmailIds( | ||
| [emailId], | ||
| markStarAction: markStarAction, | ||
| ); | ||
| } | ||
| } | ||
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
17 changes: 13 additions & 4 deletions
17
lib/features/thread/data/extensions/map_keywords_extension.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 |
|---|---|---|
| @@ -1,7 +1,16 @@ | ||
|
|
||
| import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart'; | ||
|
|
||
| extension MapKeywordsExtension on Map<KeyWordIdentifier, bool> { | ||
| extension MapKeywordsExtension on Map<KeyWordIdentifier, bool>? { | ||
| Map<String, bool> toMapString() => Map.fromIterables( | ||
| this?.keys.map((keyword) => keyword.value) ?? {}, | ||
| this?.values ?? [], | ||
| ); | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Map<KeyWordIdentifier, bool> withKeyword(KeyWordIdentifier keyword) { | ||
| return Map<KeyWordIdentifier, bool>.from(this ?? {})..[keyword] = true; | ||
| } | ||
|
|
||
| Map<String, bool> toMapString() => Map.fromIterables(keys.map((keyword) => keyword.value), values); | ||
| } | ||
| Map<KeyWordIdentifier, bool> withoutKeyword(KeyWordIdentifier keyword) { | ||
| return Map<KeyWordIdentifier, bool>.from(this ?? {})..remove(keyword); | ||
| } | ||
| } | ||
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
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.