@@ -27,22 +27,13 @@ async function toggleSidebar(sidebarEl: HTMLElement, shouldShow: boolean) {
2727}
2828
2929function childrenLoader ( sidebarEl : HTMLElement ) {
30- return async ( path : string , recursive ?: boolean ) => {
30+ return async ( treePath : string , subPath : string = '' ) => {
3131 const fileTree = sidebarEl . querySelector ( '#view-file-tree' ) ;
32- const apiBaseUrl = fileTree . getAttribute ( 'data-api-base-url' ) ;
32+ const baseUrl = fileTree . getAttribute ( 'data-api-base-url' ) ;
3333 const refTypeNameSubURL = fileTree . getAttribute ( 'data-current-ref-type-name-sub-url' ) ;
34- const response = await GET ( `${ apiBaseUrl } /tree/${ refTypeNameSubURL } /${ pathEscapeSegments ( path ?? '' ) } ?recursive =${ recursive ?? false } ` ) ;
34+ const response = await GET ( `${ baseUrl } /tree/${ refTypeNameSubURL } /${ pathEscapeSegments ( treePath ) } ?sub_path =${ encodeURIComponent ( subPath ) } ` ) ;
3535 const json = await response . json ( ) ;
36- if ( json instanceof Array ) {
37- return json . map ( ( i ) => ( {
38- name : i . name ,
39- type : i . type ,
40- path : i . path ,
41- sub_module_url : i . sub_module_url ,
42- children : i . children ,
43- } ) ) ;
44- }
45- return null ;
36+ return json . fileTreeNodes ?? null ;
4637 } ;
4738}
4839
@@ -80,7 +71,7 @@ export async function initViewFileTreeSidebar() {
8071
8172 const selectedItem = ref ( getSelectedPath ( refString ) ) ;
8273
83- const files = await childrenLoader ( sidebarEl ) ( treePath , true ) ;
74+ const files = await childrenLoader ( sidebarEl ) ( '' , treePath ) ;
8475
8576 fileTree . classList . remove ( 'is-loading' ) ;
8677 const fileTreeView = createApp ( ViewFileTree , { files, selectedItem, loadChildren : childrenLoader ( sidebarEl ) , loadContent : ( path : string ) => {
0 commit comments