File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export class PostCat {
1010 childCount = 0
1111 visibleChildCount = 0
1212 parent ?: PostCat | null
13+ children ?: PostCat | null
1314
1415 flattenParents ( includeSelf : boolean ) : PostCat [ ] {
1516 // eslint-disable-next-line @typescript-eslint/no-this-alias
Original file line number Diff line number Diff line change @@ -28,6 +28,21 @@ export namespace PostCatService {
2828 }
2929 }
3030
31+ export async function getFlatAll ( ) {
32+ const categories = await getAll ( )
33+
34+ const flat = [ ]
35+ const queue = categories
36+ while ( queue . length > 0 ) {
37+ const current = queue . pop ( )
38+ flat . push ( current )
39+
40+ if ( current ?. children != null ) for ( const child of current . children ) queue . unshift ( child )
41+ }
42+
43+ return flat
44+ }
45+
3146 export async function getOne ( categoryId : number ) {
3247 const req = await getAuthedPostCatReq ( )
3348 try {
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ export namespace PostCfgPanel {
7676 command : Webview . Cmd . Ui . editPostCfg ,
7777 post : cloneDeep ( post ) ,
7878 activeTheme : vscode . window . activeColorTheme . kind ,
79- userCats : cloneDeep ( await PostCatService . getAll ( ) ) ,
79+ userCats : cloneDeep ( await PostCatService . getFlatAll ( ) ) ,
8080 siteCats : cloneDeep ( await PostCatService . getSitePresetList ( ) ) ,
8181 tags,
8282 breadcrumbs,
You can’t perform that action at this time.
0 commit comments