TF-3385 Update save and remove draft email

This commit is contained in:
DatDang
2025-01-02 08:55:08 +07:00
committed by Dat H. Pham
parent 571ffc4dbd
commit 059185660e
9 changed files with 88 additions and 11 deletions
@@ -107,6 +107,20 @@ class MailboxTree with EquatableMixin {
return false;
}
bool updateMailboxTotalEmailsCountById(MailboxId mailboxId, int totalEmailsCount) {
final matchedNode = findNode((node) => node.item.id == mailboxId);
if (matchedNode != null) {
final currentTotalEmailsCount = matchedNode.item.totalEmails?.value.value ?? 0;
final updatedTotalEmailsCount = currentTotalEmailsCount + totalEmailsCount;
if (updatedTotalEmailsCount < 0) return true;
matchedNode.item = matchedNode.item.copyWith(
totalEmails: TotalEmails(UnsignedInt(updatedTotalEmailsCount)),
);
return true;
}
return false;
}
String? getNodePath(MailboxId mailboxId) {
final matchedNode = findNode((node) => node.item.id == mailboxId);
if (matchedNode == null) {