Fix typical bugs

This commit is contained in:
Thomas Nordquist
2019-06-26 12:12:28 +02:00
parent fc5a5d2035
commit 188b5c6c16
5 changed files with 12 additions and 10 deletions

View File

@@ -4,16 +4,17 @@ import { TopicViewModel } from './model/TopicViewModel'
export function sortedNodes(settings: SettingsState, treeNode: q.TreeNode<any>): Array<q.TreeNode<TopicViewModel>> {
const topicOrder = settings.get('topicOrder')
let edges = treeNode.edgeArray
const edges = [...treeNode.edgeArray]
if (topicOrder === TopicOrder.abc) {
edges = edges.sort((a, b) => a.name.localeCompare(b.name))
edges.sort((a, b) => a.name.localeCompare(b.name))
}
let nodes = edges.map(edge => edge.target)
const nodes = edges.map(edge => edge.target)
if (topicOrder === TopicOrder.messages) {
nodes = nodes.sort((a, b) => b.leafMessageCount() - a.leafMessageCount())
nodes.sort((a, b) => b.leafMessageCount() - a.leafMessageCount())
}
if (topicOrder === TopicOrder.topics) {
nodes = nodes.sort((a, b) => b.childTopicCount() - a.childTopicCount())
nodes.sort((a, b) => b.childTopicCount() - a.childTopicCount())
}
return nodes
}