@@ -30,7 +30,7 @@ export class GettingStartedIndexList<T extends { id: string; when?: ContextKeyEx
30
30
private list : HTMLUListElement ;
31
31
private scrollbar : DomScrollableElement ;
32
32
33
- private entries : T [ ] ;
33
+ private entries : undefined | T [ ] ;
34
34
35
35
private lastRendered : string [ ] | undefined ;
36
36
@@ -48,7 +48,7 @@ export class GettingStartedIndexList<T extends { id: string; when?: ContextKeyEx
48
48
49
49
this . contextService = options . contextService ;
50
50
51
- this . entries = [ ] ;
51
+ this . entries = undefined ;
52
52
53
53
this . itemCount = 0 ;
54
54
this . list = $ ( 'ul' ) ;
@@ -93,27 +93,27 @@ export class GettingStartedIndexList<T extends { id: string; when?: ContextKeyEx
93
93
this . setEntries ( this . entries ) ;
94
94
}
95
95
96
- setEntries ( entries : T [ ] ) {
96
+ setEntries ( entries : undefined | T [ ] ) {
97
+ const entryList = entries ?? [ ] ;
98
+
97
99
this . itemCount = 0 ;
98
100
99
101
const ranker = this . options . rankElement ;
100
102
if ( ranker ) {
101
- entries = entries . filter ( e => ranker ( e ) !== null ) ;
102
- entries . sort ( ( a , b ) => ranker ( b ) ! - ranker ( a ) ! ) ;
103
+ entries = entryList . filter ( e => ranker ( e ) !== null ) ;
104
+ entryList . sort ( ( a , b ) => ranker ( b ) ! - ranker ( a ) ! ) ;
103
105
}
104
106
105
-
106
- this . entries = entries ;
107
-
108
- const activeEntries = entries . filter ( e => ! e . when || this . contextService . contextMatchesRules ( e . when ) ) ;
107
+ const activeEntries = entryList . filter ( e => ! e . when || this . contextService . contextMatchesRules ( e . when ) ) ;
109
108
const limitedEntries = activeEntries . slice ( 0 , this . options . limit ) ;
110
109
111
110
const toRender = limitedEntries . map ( e => e . id ) ;
112
111
113
- if ( equals ( toRender , this . lastRendered ) ) { return ; }
112
+ if ( this . entries === entries && equals ( toRender , this . lastRendered ) ) { return ; }
113
+ this . entries = entries ;
114
114
115
115
this . contextKeysToWatch . clear ( ) ;
116
- entries . forEach ( e => {
116
+ entryList . forEach ( e => {
117
117
const keys = e . when ?. keys ( ) ;
118
118
if ( keys ) {
119
119
keys . forEach ( key => this . contextKeysToWatch . add ( key ) ) ;
@@ -137,7 +137,7 @@ export class GettingStartedIndexList<T extends { id: string; when?: ContextKeyEx
137
137
if ( activeEntries . length > limitedEntries . length && this . options . more ) {
138
138
this . list . appendChild ( this . options . more ) ;
139
139
}
140
- else if ( this . itemCount === 0 && this . options . empty ) {
140
+ else if ( entries !== undefined && this . itemCount === 0 && this . options . empty ) {
141
141
this . list . appendChild ( this . options . empty ) ;
142
142
}
143
143
else if ( this . options . footer ) {
0 commit comments