From c1ae1332744a90d98ce5f65563bde44967965518 Mon Sep 17 00:00:00 2001 From: DatDang Date: Fri, 3 Jan 2025 17:01:26 +0700 Subject: [PATCH] TF-3385 Fix change flags not working --- .../presentation/controller/single_email_controller.dart | 7 +++++++ .../update_current_emails_flags_extension.dart | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/features/email/presentation/controller/single_email_controller.dart b/lib/features/email/presentation/controller/single_email_controller.dart index a7676a5c62..558d776d7b 100644 --- a/lib/features/email/presentation/controller/single_email_controller.dart +++ b/lib/features/email/presentation/controller/single_email_controller.dart @@ -1131,6 +1131,13 @@ class SingleEmailController extends BaseController with AppLoaderMixin { KeyWordIdentifier.emailFlagged: success.markStarAction == MarkStarAction.markStar, }); mailboxDashBoardController.setSelectedEmail(newEmail); + + final emailId = newEmail?.id; + if (emailId == null) return; + mailboxDashBoardController.updateEmailFlagByEmailIds( + [emailId], + markStarAction: success.markStarAction, + ); } void handleEmailAction(BuildContext context, PresentationEmail presentationEmail, EmailActionType actionType) { diff --git a/lib/features/mailbox_dashboard/presentation/extensions/update_current_emails_flags_extension.dart b/lib/features/mailbox_dashboard/presentation/extensions/update_current_emails_flags_extension.dart index 4572d768a7..f0771be0f4 100644 --- a/lib/features/mailbox_dashboard/presentation/extensions/update_current_emails_flags_extension.dart +++ b/lib/features/mailbox_dashboard/presentation/extensions/update_current_emails_flags_extension.dart @@ -4,6 +4,7 @@ import 'package:model/email/mark_star_action.dart'; import 'package:model/email/presentation_email.dart'; import 'package:model/email/read_actions.dart'; import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart'; +import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/dashboard_routes.dart'; extension UpdateCurrentEmailsFlagsExtension on MailboxDashBoardController { void updateEmailFlagByEmailIds( @@ -13,7 +14,11 @@ extension UpdateCurrentEmailsFlagsExtension on MailboxDashBoardController { }) { if (readAction == null && markStarAction == null) return; - for (var email in emailsInCurrentMailbox) { + final currentEmails = dashboardRoute.value == DashboardRoutes.searchEmail + ? listResultSearch + : emailsInCurrentMailbox; + + for (var email in currentEmails) { if (!emailIds.contains(email.id)) continue; switch (readAction) { @@ -39,7 +44,7 @@ extension UpdateCurrentEmailsFlagsExtension on MailboxDashBoardController { } } - emailsInCurrentMailbox.refresh(); + currentEmails.refresh(); } void _updateKeyword(