Skip to content

Commit

Permalink
ui: child nodes also sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
typeholes committed Jun 9, 2024
1 parent 01229d5 commit 22d6328
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ui/components/TreeNode.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script setup lang="ts">
import type { Tree } from '../../shared/src/tree'
import { childrenById, typesById } from '~/src/appState'
import { childrenById, doSort, typesById } from '~/src/appState'
const props = defineProps<{ tree: Tree, depth: number }>()
const sendMessage = useNuxtApp().$sendMessage
const children = computed(() => childrenById.get(props.tree.id) ?? [])
const children = computed(() => doSort(childrenById.get(props.tree.id) ?? []))
const types = computed(() => typesById.get(props.tree.id) ?? [])
function fetchChildren() {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/appState.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TypeLine } from '../../shared/src/traceData'
import type { Tree } from '../../src/traceTree'
import type { Tree } from '../../shared/src/tree'
import * as Messages from '../../shared/src/messages'

export const childrenById = shallowReactive(new Map<number, Tree[]>())
Expand All @@ -21,7 +21,7 @@ const sortValue = {
'Total Types': (t: Tree) => -(t.childTypeCnt + t.typeCnt),
} as const

function doSort(arr: Tree[]) {
export function doSort(arr: Tree[]) {
const ord = sortValue[sortBy.value]
return ord ? arr.toSorted((a, b) => ord(a) - ord(b)) : arr
}
Expand Down

0 comments on commit 22d6328

Please sign in to comment.