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) {
|
||||
final folder = _buildActionRequiredFolder(count);
|
||||
|
||||
_addToDefaultMailboxTree(folder);
|
||||
_addToDefaultMailboxTree(folder, count);
|
||||
_addToAllMailboxes(folder);
|
||||
}
|
||||
|
||||
@@ -43,20 +43,23 @@ extension HandleActionRequiredTabExtension on BaseMailboxController {
|
||||
return base.copyWith(
|
||||
displayName:
|
||||
currentContext != null ? base.getDisplayName(currentContext!) : null,
|
||||
totalEmails: TotalEmails(UnsignedInt(count)),
|
||||
unreadEmails: UnreadEmails(UnsignedInt(count)),
|
||||
);
|
||||
}
|
||||
|
||||
void _addToDefaultMailboxTree(PresentationMailbox folder) {
|
||||
void _addToDefaultMailboxTree(PresentationMailbox folder, int count) {
|
||||
final root = defaultMailboxTree.value.root;
|
||||
final children = List<MailboxNode>.from(root.childrenItems ?? []);
|
||||
|
||||
children.insertAfterStarredOrInbox(MailboxNode(folder));
|
||||
final result = children.insertAfterStarredOrInbox(MailboxNode(folder));
|
||||
|
||||
defaultMailboxTree.value = MailboxTree(
|
||||
root.copyWith(children: children),
|
||||
);
|
||||
if (result) {
|
||||
defaultMailboxTree.value = MailboxTree(
|
||||
root.copyWith(children: children),
|
||||
);
|
||||
} else {
|
||||
defaultMailboxTree.value.updateMailboxUnreadCountById(folder.id, count);
|
||||
}
|
||||
}
|
||||
|
||||
void _addToAllMailboxes(PresentationMailbox folder) {
|
||||
|
||||
@@ -15,8 +15,8 @@ extension ListMailboxNodeExtension on List<MailboxNode> {
|
||||
|
||||
/// Insert [newNode] after Starred if present,
|
||||
/// otherwise after Inbox, otherwise at the beginning.
|
||||
void insertAfterStarredOrInbox(MailboxNode newNode) {
|
||||
insertAfterByPriority(
|
||||
bool insertAfterStarredOrInbox(MailboxNode newNode) {
|
||||
return insertAfterByPriority(
|
||||
newNode,
|
||||
[
|
||||
_isStarred,
|
||||
@@ -27,21 +27,22 @@ extension ListMailboxNodeExtension on List<MailboxNode> {
|
||||
|
||||
/// Insert [newNode] after the first mailbox matching [priorities].
|
||||
/// If none match, inserts at the beginning.
|
||||
void insertAfterByPriority(
|
||||
bool insertAfterByPriority(
|
||||
MailboxNode newNode,
|
||||
List<bool Function(MailboxNode)> priorities,
|
||||
) {
|
||||
if (_containsMailbox(newNode)) return;
|
||||
if (_containsMailbox(newNode)) return false;
|
||||
|
||||
for (final predicate in priorities) {
|
||||
final index = indexWhere(predicate);
|
||||
if (index != -1) {
|
||||
insert(index + 1, newNode);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
insert(0, newNode);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _isInbox(MailboxNode node) {
|
||||
|
||||
@@ -611,6 +611,7 @@ class MailboxController extends BaseMailboxController
|
||||
syncAllMailboxWithDisplayName(currentContext!);
|
||||
}
|
||||
addFavoriteFolderToMailboxList();
|
||||
setUpActionRequiredFolder(mailboxDashBoardController);
|
||||
_setMapMailbox();
|
||||
_setOutboxMailbox();
|
||||
_selectSelectedMailboxDefault();
|
||||
|
||||
Reference in New Issue
Block a user