Refactor TreeNode model
This commit is contained in:
@@ -52,9 +52,12 @@ export class TreeNode<ViewModel extends Destroyable> {
|
|||||||
return this.sourceEdge ? this.sourceEdge.source || undefined : undefined
|
return this.sourceEdge ? this.sourceEdge.source || undefined : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private hasMessage() {
|
||||||
|
return this.message && this.message.value && this.message.value.length !== 0
|
||||||
|
}
|
||||||
|
|
||||||
private isTopicEmptyLeaf() {
|
private isTopicEmptyLeaf() {
|
||||||
const hasNoMessage = !this.message || !this.message.value || this.message.value.length === 0
|
return !this.hasMessage() && this.isLeaf()
|
||||||
return hasNoMessage && this.isLeaf()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private isLeaf() {
|
private isLeaf() {
|
||||||
@@ -221,7 +224,7 @@ export class TreeNode<ViewModel extends Destroyable> {
|
|||||||
if (this.cachedChildTopicCount === undefined) {
|
if (this.cachedChildTopicCount === undefined) {
|
||||||
this.cachedChildTopicCount = this.edgeArray
|
this.cachedChildTopicCount = this.edgeArray
|
||||||
.map(e => e.target.childTopicCount())
|
.map(e => e.target.childTopicCount())
|
||||||
.reduce((a, b) => a + b, this.edgeArray.length === 0 ? 1 : 0)
|
.reduce((a, b) => a + b, this.hasMessage() ? 1 : 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.cachedChildTopicCount as number
|
return this.cachedChildTopicCount as number
|
||||||
|
|||||||
Reference in New Issue
Block a user