TF-3385 Update mark as read and star

This commit is contained in:
DatDang
2024-12-31 10:12:43 +07:00
committed by Dat H. Pham
parent a94513efb4
commit 8f5168ec6b
24 changed files with 521 additions and 32 deletions
@@ -568,4 +568,41 @@ abstract class BaseMailboxController extends BaseController {
}
}
}
void updateUnreadCountOfMailboxById(
MailboxId mailboxId, {
required int unreadChanges,
}) {
final mailboxTrees = [
defaultMailboxTree,
personalMailboxTree,
teamMailboxesTree,
];
for (var mailboxTree in mailboxTrees) {
if (mailboxTree.value.updateMailboxUnreadCountById(mailboxId, unreadChanges)) {
mailboxTree.refresh();
break;
}
}
}
void clearUnreadCount(MailboxId mailboxId) {
final mailboxTrees = [
defaultMailboxTree,
personalMailboxTree,
teamMailboxesTree,
];
for (var mailboxTree in mailboxTrees) {
final selectedNode = mailboxTree.value.findNode((node) => node.item.id == mailboxId);
if (selectedNode == null) continue;
final currentUnreadCount = selectedNode.item.unreadEmails?.value.value.toInt();
teamMailboxesTree.value.updateMailboxUnreadCountById(
mailboxId,
-(currentUnreadCount ?? 0));
teamMailboxesTree.refresh();
break;
}
}
}