@@ -17,20 +17,17 @@ export class ListCollection<T> implements Collection<Node<T>> {
17
17
private iterable : Iterable < Node < T > > ;
18
18
private firstKey : Key | null = null ;
19
19
private lastKey : Key | null = null ;
20
+ private _size : number ;
20
21
21
22
constructor ( nodes : Iterable < Node < T > > ) {
22
23
this . iterable = nodes ;
23
24
24
25
let visit = ( node : Node < T > ) => {
25
- // Skip the loader node so it isn't added to the keymap and thus
26
- // doesn't influence the size count. This should only matter for RAC and S2
27
- if ( node . type !== 'loader' ) {
28
- this . keyMap . set ( node . key , node ) ;
29
-
30
- if ( node . childNodes && node . type === 'section' ) {
31
- for ( let child of node . childNodes ) {
32
- visit ( child ) ;
33
- }
26
+ this . keyMap . set ( node . key , node ) ;
27
+
28
+ if ( node . childNodes && node . type === 'section' ) {
29
+ for ( let child of node . childNodes ) {
30
+ visit ( child ) ;
34
31
}
35
32
}
36
33
} ;
@@ -41,6 +38,7 @@ export class ListCollection<T> implements Collection<Node<T>> {
41
38
42
39
let last : Node < T > | null = null ;
43
40
let index = 0 ;
41
+ let size = 0 ;
44
42
for ( let [ key , node ] of this . keyMap ) {
45
43
if ( last ) {
46
44
last . nextKey = key ;
@@ -54,13 +52,19 @@ export class ListCollection<T> implements Collection<Node<T>> {
54
52
node . index = index ++ ;
55
53
}
56
54
55
+ // Only count sections and items when determining size so that
56
+ // loaders and separators in RAC/S2 don't influence the emptyState determination
57
+ if ( node . type === 'section' || node . type === 'item' ) {
58
+ size ++ ;
59
+ }
60
+
57
61
last = node ;
58
62
59
63
// Set nextKey as undefined since this might be the last node
60
64
// If it isn't the last node, last.nextKey will properly set at start of new loop
61
65
last . nextKey = undefined ;
62
66
}
63
-
67
+ this . _size = size ;
64
68
this . lastKey = last ?. key ?? null ;
65
69
}
66
70
@@ -69,7 +73,7 @@ export class ListCollection<T> implements Collection<Node<T>> {
69
73
}
70
74
71
75
get size ( ) : number {
72
- return this . keyMap . size ;
76
+ return this . _size ;
73
77
}
74
78
75
79
getKeys ( ) : IterableIterator < Key > {
0 commit comments