File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " preact-signals-devtools " : minor
3+ ---
4+
5+ Automatically fold child updates and show first/last value.
Original file line number Diff line number Diff line change @@ -17,6 +17,24 @@ export function UpdateTreeNodeComponent({ node }: UpdateTreeNodeProps) {
1717 const nodeCount = node . type === "group" ? node . count : undefined ;
1818 const firstUpdate = node . type === "group" ? node . firstUpdate : undefined ;
1919
20+ let childrenToRender : UpdateTreeNode [ ] ;
21+
22+ if ( node . type === "group" && node . firstChildren ) {
23+ childrenToRender = node . children . map ( ( lastChild , index ) => {
24+ const firstChild = node . firstChildren [ index ] ;
25+ const mergedChild : UpdateTreeNode = {
26+ ...lastChild ,
27+ type : "group" ,
28+ firstUpdate : firstChild . update ,
29+ firstChildren : firstChild . children ,
30+ count : node . count ,
31+ } ;
32+ return mergedChild ;
33+ } ) ;
34+ } else {
35+ childrenToRender = node . children ;
36+ }
37+
2038 return (
2139 < div className = "tree-node" >
2240 < div className = "tree-node-content" >
@@ -41,7 +59,7 @@ export function UpdateTreeNodeComponent({ node }: UpdateTreeNodeProps) {
4159
4260 { hasChildren && ! isCollapsed . value && (
4361 < div className = "tree-children" >
44- { node . children . map ( child => (
62+ { childrenToRender . map ( child => (
4563 < UpdateTreeNodeComponent key = { child . id } node = { child } />
4664 ) ) }
4765 </ div >
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ export interface UpdateTreeNodeGroup extends UpdateTreeNodeBase {
1818 type : "group" ;
1919 count : number ;
2020 firstUpdate : SignalUpdate ;
21+ firstChildren : UpdateTreeNode [ ] ;
2122}
2223
2324export type UpdateTreeNode = UpdateTreeNodeGroup | UpdateTreeNodeSingle ;
@@ -44,11 +45,13 @@ const collapseTree = (nodes: UpdateTreeNodeSingle[]): UpdateTreeNode[] => {
4445 type : "group" ,
4546 count : 2 ,
4647 firstUpdate : node . update ,
48+ firstChildren : node . children ,
4749 } ;
4850 tree . push ( lastNode ) ;
4951 } else {
5052 lastNode . count ++ ;
5153 lastNode . firstUpdate = node . update ;
54+ lastNode . firstChildren = node . children ;
5255 }
5356 // If the current node is equal to the last one, skip it
5457 continue ;
You can’t perform that action at this time.
0 commit comments