Skip to content

Commit

Permalink
improve code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip-Carneiro-KX committed Aug 16, 2024
1 parent b7ab225 commit f32f58d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/services/kdbTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -821,14 +821,8 @@ export class LabelNode extends TreeItem {
readonly children: TreeItem[] = [];

constructor(public readonly source: Labels) {
super(
source.name,
isLabelEmpty(source.name)
? TreeItemCollapsibleState.None
: isLabelContentChanged(source.name)
? TreeItemCollapsibleState.Expanded
: TreeItemCollapsibleState.Collapsed,
);
super(source.name);
this.collapsibleState = this.getCollapsibleState(source.name);
this.contextValue = "label";
}

Expand All @@ -852,4 +846,14 @@ export class LabelNode extends TreeItem {
`label-${this.source.color.name.toLowerCase()}.svg`,
),
};

getCollapsibleState(labelName: string): TreeItemCollapsibleState {
if (isLabelEmpty(labelName)) {
return TreeItemCollapsibleState.None;
}
if (isLabelContentChanged(labelName)) {
return TreeItemCollapsibleState.Expanded;
}
return TreeItemCollapsibleState.Collapsed;
}
}

0 comments on commit f32f58d

Please sign in to comment.