TF-1868 Fix a mailbox is visible then it's parents needs to be visible too

(cherry picked from commit 02a505fc6241ffb4df7559004e8dae718f13d39e)
This commit is contained in:
dab246
2023-07-11 22:54:39 +07:00
committed by Dat Vu
parent e35b1d47aa
commit 89d32cb88c
3 changed files with 87 additions and 8 deletions
@@ -21,6 +21,8 @@ class MailboxNode with EquatableMixin{
bool hasChildren() => childrenItems?.isNotEmpty ?? false;
bool hasParents() => item.hasParentId();
bool get isActivated => nodeState == MailboxState.activated;
bool get isSelected => selectMode == SelectMode.ACTIVE;
@@ -111,6 +111,20 @@ class MailboxTree with EquatableMixin {
return path;
}
List<MailboxNode>? getAncestorList(MailboxNode mailboxNode) {
var parentId = mailboxNode.item.parentId;
List<MailboxNode> ancestor = <MailboxNode>[];
while(parentId != null) {
final parentNode = findNode((node) => node.item.id == parentId);
if (parentNode == null) {
break;
}
ancestor.add(parentNode);
parentId = parentNode.item.parentId;
}
return ancestor.isNotEmpty ? ancestor : null;
}
Map<Role, PresentationMailbox> get mapPresentationMailboxByRole {
if (root.childrenItems?.isEmpty == true) {
return {};