@@ -37,6 +37,9 @@ import { Helmet } from 'react-helmet';
3737import PropTypes from 'lib/PropTypes' ;
3838import ParseApp from 'lib/ParseApp' ;
3939
40+ // The initial and max amount of rows fetched by lazy loading
41+ const MAX_ROWS_FETCHED = 200 ;
42+
4043export default
4144@subscribeTo ( 'Schema' , 'schema' )
4245class Browser extends DashboardView {
@@ -337,7 +340,7 @@ class Browser extends DashboardView {
337340 query . ascending ( field )
338341 }
339342
340- query . limit ( 200 ) ;
343+ query . limit ( MAX_ROWS_FETCHED ) ;
341344
342345 let promise = query . find ( { useMasterKey : true } ) ;
343346 let isUnique = false ;
@@ -374,7 +377,7 @@ class Browser extends DashboardView {
374377 } else {
375378 delete filteredCounts [ source ] ;
376379 }
377- this . setState ( { data : data , filters, lastMax : 200 , filteredCounts : filteredCounts } ) ;
380+ this . setState ( { data : data , filters, lastMax : MAX_ROWS_FETCHED , filteredCounts : filteredCounts } ) ;
378381 }
379382
380383 async fetchRelation ( relation , filters = new List ( ) ) {
@@ -386,7 +389,7 @@ class Browser extends DashboardView {
386389 selection : { } ,
387390 data,
388391 filters,
389- lastMax : 200 ,
392+ lastMax : MAX_ROWS_FETCHED ,
390393 } ) ;
391394 }
392395
@@ -429,14 +432,16 @@ class Browser extends DashboardView {
429432 query . lessThan ( 'createdAt' , this . state . data [ this . state . data . length - 1 ] . get ( 'createdAt' ) ) ;
430433 }
431434 query . addDescending ( 'createdAt' ) ;
432- query . limit ( 200 ) ;
435+ query . limit ( MAX_ROWS_FETCHED ) ;
433436
434437 query . find ( { useMasterKey : true } ) . then ( ( nextPage ) => {
435438 if ( className === this . props . params . className ) {
436- this . setState ( ( state ) => ( { data : state . data . concat ( nextPage ) } ) ) ;
439+ this . setState ( ( state ) => ( {
440+ data : state . data . concat ( nextPage )
441+ } ) ) ;
437442 }
438443 } ) ;
439- this . setState ( { lastMax : this . state . lastMax + 200 } ) ;
444+ this . setState ( { lastMax : this . state . lastMax + MAX_ROWS_FETCHED } ) ;
440445 }
441446
442447 updateFilters ( filters ) {
@@ -587,7 +592,7 @@ class Browser extends DashboardView {
587592 this . state . counts [ className ] = 0 ;
588593 this . setState ( {
589594 data : [ ] ,
590- lastMax : 200 ,
595+ lastMax : MAX_ROWS_FETCHED ,
591596 selection : { } ,
592597 } ) ;
593598 }
@@ -640,7 +645,14 @@ class Browser extends DashboardView {
640645 this . state . data . splice ( indexes [ i ] - i , 1 ) ;
641646 }
642647 this . state . counts [ className ] -= indexes . length ;
643- this . forceUpdate ( ) ;
648+
649+ // If after deletion, the remaining elements on the table is lesser than the maximum allowed elements
650+ // we fetch more data to fill the table
651+ if ( this . state . data . length < MAX_ROWS_FETCHED ) {
652+ this . prefetchData ( this . props , this . context ) ;
653+ } else {
654+ this . forceUpdate ( ) ;
655+ }
644656 }
645657 } , ( error ) => {
646658 let errorDeletingNote = null ;
@@ -669,9 +681,6 @@ class Browser extends DashboardView {
669681
670682 selectRow ( id , checked ) {
671683 this . setState ( ( { selection } ) => {
672- if ( id === '*' ) {
673- return { selection : checked ? { '*' : true } : { } } ;
674- }
675684 if ( checked ) {
676685 selection [ id ] = true ;
677686 } else {
0 commit comments