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 {
10
10
childCount = 0
11
11
visibleChildCount = 0
12
12
parent ?: PostCat | null
13
+ children ?: PostCat | null
13
14
14
15
flattenParents ( includeSelf : boolean ) : PostCat [ ] {
15
16
// 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 {
28
28
}
29
29
}
30
30
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 ) current . children . forEach ( child => queue . unshift ( child ) )
41
+ }
42
+
43
+ return flat
44
+ }
45
+
31
46
export async function getOne ( categoryId : number ) {
32
47
const req = await getAuthedPostCatReq ( )
33
48
try {
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ export namespace PostCfgPanel {
76
76
command : Webview . Cmd . Ui . editPostCfg ,
77
77
post : cloneDeep ( post ) ,
78
78
activeTheme : vscode . window . activeColorTheme . kind ,
79
- userCats : cloneDeep ( await PostCatService . getAll ( ) ) ,
79
+ userCats : cloneDeep ( await PostCatService . getFlatAll ( ) ) ,
80
80
siteCats : cloneDeep ( await PostCatService . getSitePresetList ( ) ) ,
81
81
tags,
82
82
breadcrumbs,
You can’t perform that action at this time.
0 commit comments