TF-4141 Auto refresh count emails in Action required folder when email changed
This commit is contained in:
+10
-7
@@ -33,7 +33,7 @@ extension HandleActionRequiredTabExtension on BaseMailboxController {
|
|||||||
void _addActionRequiredFolder(int count) {
|
void _addActionRequiredFolder(int count) {
|
||||||
final folder = _buildActionRequiredFolder(count);
|
final folder = _buildActionRequiredFolder(count);
|
||||||
|
|
||||||
_addToDefaultMailboxTree(folder);
|
_addToDefaultMailboxTree(folder, count);
|
||||||
_addToAllMailboxes(folder);
|
_addToAllMailboxes(folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,20 +43,23 @@ extension HandleActionRequiredTabExtension on BaseMailboxController {
|
|||||||
return base.copyWith(
|
return base.copyWith(
|
||||||
displayName:
|
displayName:
|
||||||
currentContext != null ? base.getDisplayName(currentContext!) : null,
|
currentContext != null ? base.getDisplayName(currentContext!) : null,
|
||||||
totalEmails: TotalEmails(UnsignedInt(count)),
|
|
||||||
unreadEmails: UnreadEmails(UnsignedInt(count)),
|
unreadEmails: UnreadEmails(UnsignedInt(count)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _addToDefaultMailboxTree(PresentationMailbox folder) {
|
void _addToDefaultMailboxTree(PresentationMailbox folder, int count) {
|
||||||
final root = defaultMailboxTree.value.root;
|
final root = defaultMailboxTree.value.root;
|
||||||
final children = List<MailboxNode>.from(root.childrenItems ?? []);
|
final children = List<MailboxNode>.from(root.childrenItems ?? []);
|
||||||
|
|
||||||
children.insertAfterStarredOrInbox(MailboxNode(folder));
|
final result = children.insertAfterStarredOrInbox(MailboxNode(folder));
|
||||||
|
|
||||||
defaultMailboxTree.value = MailboxTree(
|
if (result) {
|
||||||
root.copyWith(children: children),
|
defaultMailboxTree.value = MailboxTree(
|
||||||
);
|
root.copyWith(children: children),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
defaultMailboxTree.value.updateMailboxUnreadCountById(folder.id, count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _addToAllMailboxes(PresentationMailbox folder) {
|
void _addToAllMailboxes(PresentationMailbox folder) {
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ extension ListMailboxNodeExtension on List<MailboxNode> {
|
|||||||
|
|
||||||
/// Insert [newNode] after Starred if present,
|
/// Insert [newNode] after Starred if present,
|
||||||
/// otherwise after Inbox, otherwise at the beginning.
|
/// otherwise after Inbox, otherwise at the beginning.
|
||||||
void insertAfterStarredOrInbox(MailboxNode newNode) {
|
bool insertAfterStarredOrInbox(MailboxNode newNode) {
|
||||||
insertAfterByPriority(
|
return insertAfterByPriority(
|
||||||
newNode,
|
newNode,
|
||||||
[
|
[
|
||||||
_isStarred,
|
_isStarred,
|
||||||
@@ -27,21 +27,22 @@ extension ListMailboxNodeExtension on List<MailboxNode> {
|
|||||||
|
|
||||||
/// Insert [newNode] after the first mailbox matching [priorities].
|
/// Insert [newNode] after the first mailbox matching [priorities].
|
||||||
/// If none match, inserts at the beginning.
|
/// If none match, inserts at the beginning.
|
||||||
void insertAfterByPriority(
|
bool insertAfterByPriority(
|
||||||
MailboxNode newNode,
|
MailboxNode newNode,
|
||||||
List<bool Function(MailboxNode)> priorities,
|
List<bool Function(MailboxNode)> priorities,
|
||||||
) {
|
) {
|
||||||
if (_containsMailbox(newNode)) return;
|
if (_containsMailbox(newNode)) return false;
|
||||||
|
|
||||||
for (final predicate in priorities) {
|
for (final predicate in priorities) {
|
||||||
final index = indexWhere(predicate);
|
final index = indexWhere(predicate);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
insert(index + 1, newNode);
|
insert(index + 1, newNode);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
insert(0, newNode);
|
insert(0, newNode);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _isInbox(MailboxNode node) {
|
bool _isInbox(MailboxNode node) {
|
||||||
|
|||||||
@@ -611,6 +611,7 @@ class MailboxController extends BaseMailboxController
|
|||||||
syncAllMailboxWithDisplayName(currentContext!);
|
syncAllMailboxWithDisplayName(currentContext!);
|
||||||
}
|
}
|
||||||
addFavoriteFolderToMailboxList();
|
addFavoriteFolderToMailboxList();
|
||||||
|
setUpActionRequiredFolder(mailboxDashBoardController);
|
||||||
_setMapMailbox();
|
_setMapMailbox();
|
||||||
_setOutboxMailbox();
|
_setOutboxMailbox();
|
||||||
_selectSelectedMailboxDefault();
|
_selectSelectedMailboxDefault();
|
||||||
|
|||||||
@@ -16,4 +16,13 @@ extension HandleAiActionExtension on MailboxDashBoardController {
|
|||||||
currentAccountId,
|
currentAccountId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void autoRefreshCountEmailsInActionRequiredFolder() {
|
||||||
|
if (isAiCapabilitySupported) {
|
||||||
|
actionRequiredFolderController.getCountEmails(
|
||||||
|
session: sessionCurrent,
|
||||||
|
accountId: accountId.value,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import 'package:tmail_ui_user/features/home/data/exceptions/session_exceptions.d
|
|||||||
import 'package:tmail_ui_user/features/mailbox/domain/state/mark_as_mailbox_read_state.dart';
|
import 'package:tmail_ui_user/features/mailbox/domain/state/mark_as_mailbox_read_state.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/action/dashboard_action.dart';
|
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/action/dashboard_action.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/search_controller.dart' as search;
|
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/search_controller.dart' as search;
|
||||||
|
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/handle_ai_action_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/move_emails_to_mailbox_extension.dart';
|
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/move_emails_to_mailbox_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/open_and_close_composer_extension.dart';
|
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/open_and_close_composer_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/update_current_emails_flags_extension.dart';
|
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/update_current_emails_flags_extension.dart';
|
||||||
@@ -788,6 +789,7 @@ class ThreadController extends BaseController with EmailActionController {
|
|||||||
} else {
|
} else {
|
||||||
await _refreshChangeListEmail();
|
await _refreshChangeListEmail();
|
||||||
}
|
}
|
||||||
|
mailboxDashBoardController.autoRefreshCountEmailsInActionRequiredFolder();
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
logWarning('ThreadController::_handleWebSocketMessage:Error processing state: $e');
|
logWarning('ThreadController::_handleWebSocketMessage:Error processing state: $e');
|
||||||
onError(e, stackTrace);
|
onError(e, stackTrace);
|
||||||
|
|||||||
Reference in New Issue
Block a user