@@ -82,6 +82,7 @@ function TripleListView() {
8282 < div style = { TRIPLE_LIST_STYLE } >
8383 { openItems . length > 0 && (
8484 < div data-status-list = "open" >
85+ < span data-status-count > { openItems . length } </ span >
8586 < List
8687 style = { LIST_STYLE }
8788 rowHeight = { ITEM_HEIGHT }
@@ -93,6 +94,7 @@ function TripleListView() {
9394 ) }
9495 { closedItems . length > 0 && (
9596 < div data-status-list = "closed" >
97+ < span data-status-count > { closedItems . length } </ span >
9698 < List
9799 style = { LIST_STYLE }
98100 rowHeight = { ITEM_HEIGHT }
@@ -104,6 +106,7 @@ function TripleListView() {
104106 ) }
105107 { inProgressItems . length > 0 && (
106108 < div data-status-list = "in_progress" >
109+ < span data-status-count > { inProgressItems . length } </ span >
107110 < List
108111 style = { LIST_STYLE }
109112 rowHeight = { ITEM_HEIGHT }
@@ -165,17 +168,36 @@ function BenchmarkHarness() {
165168 setInProgressItems ( [ ] ) ;
166169 } , [ unmountBase ] ) ;
167170
171+ const refetchActiveList = useCallback ( ( ) => {
172+ if ( tripleListCount != null ) {
173+ return Promise . all ( [
174+ ItemResource . getList ( { status : 'open' , count : tripleListCount } ) . then (
175+ setOpenItems ,
176+ ) ,
177+ ItemResource . getList ( {
178+ status : 'closed' ,
179+ count : tripleListCount ,
180+ } ) . then ( setClosedItems ) ,
181+ ItemResource . getList ( {
182+ status : 'in_progress' ,
183+ count : tripleListCount ,
184+ } ) . then ( setInProgressItems ) ,
185+ ] ) ;
186+ }
187+ return ItemResource . getList ( { count : listViewCount ! } ) . then ( setItems ) ;
188+ } , [ listViewCount , tripleListCount ] ) ;
189+
168190 const updateEntity = useCallback (
169191 ( id : string ) => {
170192 const item = FIXTURE_ITEMS_BY_ID . get ( id ) ;
171193 if ( ! item ) return ;
172194 measureUpdate ( ( ) =>
173195 ItemResource . update ( { id } , { label : `${ item . label } (updated)` } ) . then (
174- ( ) => ItemResource . getList ( { count : listViewCount ! } ) . then ( setItems ) ,
196+ refetchActiveList ,
175197 ) ,
176198 ) ;
177199 } ,
178- [ measureUpdate , listViewCount ] ,
200+ [ measureUpdate , refetchActiveList ] ,
179201 ) ;
180202
181203 const updateAuthor = useCallback (
@@ -186,32 +208,26 @@ function BenchmarkHarness() {
186208 AuthorResource . update (
187209 { id : authorId } ,
188210 { name : `${ author . name } (updated)` } ,
189- ) . then ( ( ) =>
190- ItemResource . getList ( { count : listViewCount ! } ) . then ( setItems ) ,
191- ) ,
211+ ) . then ( refetchActiveList ) ,
192212 ) ;
193213 } ,
194- [ measureUpdate , listViewCount ] ,
214+ [ measureUpdate , refetchActiveList ] ,
195215 ) ;
196216
197217 const unshiftItem = useCallback ( ( ) => {
198218 const author = FIXTURE_AUTHORS [ 0 ] ;
199219 measureUpdate ( ( ) =>
200- ItemResource . create ( { label : 'New Item' , author } ) . then ( ( ) =>
201- ItemResource . getList ( { count : listViewCount ! } ) . then ( setItems ) ,
220+ ItemResource . create ( { label : 'New Item' , author } ) . then (
221+ refetchActiveList ,
202222 ) ,
203223 ) ;
204- } , [ measureUpdate , listViewCount ] ) ;
224+ } , [ measureUpdate , refetchActiveList ] ) ;
205225
206226 const deleteEntity = useCallback (
207227 ( id : string ) => {
208- measureUpdate ( ( ) =>
209- ItemResource . delete ( { id } ) . then ( ( ) =>
210- ItemResource . getList ( { count : listViewCount ! } ) . then ( setItems ) ,
211- ) ,
212- ) ;
228+ measureUpdate ( ( ) => ItemResource . delete ( { id } ) . then ( refetchActiveList ) ) ;
213229 } ,
214- [ measureUpdate , listViewCount ] ,
230+ [ measureUpdate , refetchActiveList ] ,
215231 ) ;
216232
217233 const moveItem = useCallback (
@@ -238,16 +254,22 @@ function BenchmarkHarness() {
238254 const source = containerRef . current ?. querySelector (
239255 '[data-status-list="open"]' ,
240256 ) ;
241- return source ?. querySelector ( `[data-item-id="${ id } "]` ) == null ;
257+ const dest = containerRef . current ?. querySelector (
258+ '[data-status-list="closed"]' ,
259+ ) ;
260+ return (
261+ source ?. querySelector ( `[data-item-id="${ id } "]` ) == null &&
262+ dest ?. querySelector ( `[data-item-id="${ id } "]` ) != null
263+ ) ;
242264 } ,
243265 ) ;
244266 } ,
245267 [ measureUpdate , tripleListCount , containerRef ] ,
246268 ) ;
247269
248270 const mountSortedView = useCallback (
249- ( n : number ) => {
250- seedItemList ( FIXTURE_ITEMS . slice ( 0 , n ) ) ;
271+ async ( n : number ) => {
272+ await seedItemList ( FIXTURE_ITEMS . slice ( 0 , n ) ) ;
251273 measureMount ( ( ) => {
252274 setShowSortedView ( true ) ;
253275 } ) ;
0 commit comments