@@ -66,7 +66,7 @@ const infiniteCollectionStoreCallback = async <
6666 allItems = produce ( allItems , ( draft ) => {
6767 updateIndex = draft . findIndex ( ( item ) => item . id === expandedRecord . id ) ;
6868 if ( updateIndex !== - 1 ) {
69- if ( new Date ( expandedRecord . updated ) > new Date ( draft [ updateIndex ] . updated ) ) {
69+ if ( new Date ( expandedRecord . updated ) >= new Date ( draft [ updateIndex ] . updated ) ) {
7070 draft [ updateIndex ] = expandedRecord as Draft < T > ;
7171 } else {
7272 actionIgnored = true ;
@@ -79,7 +79,7 @@ const infiniteCollectionStoreCallback = async <
7979 case 'delete' :
8080 allItems = produce ( allItems , ( draft ) => {
8181 deleteIndex = draft . findIndex ( ( item ) => item . id === expandedRecord . id ) ;
82- if ( new Date ( expandedRecord . updated ) > new Date ( draft [ deleteIndex ] . updated ) ) {
82+ if ( new Date ( expandedRecord . updated ) >= new Date ( draft [ deleteIndex ] . updated ) ) {
8383 draft . splice ( deleteIndex , 1 ) ;
8484 } else {
8585 actionIgnored = true ;
@@ -165,9 +165,10 @@ const infiniteCollectionStoreCallback = async <
165165
166166 if (
167167 totalItemsWeHave === totalItemsInDatabase &&
168+ data . pages . length > 1 &&
168169 data . pages [ data . pages . length - 1 ] . items . length === 0
169170 ) {
170- // delete empty pages only if we have all items in the database
171+ // delete empty pages only if we have all items in the database, and there is at least one page
171172 data = produce ( data , ( draft ) => {
172173 draft . pages . pop ( ) ;
173174 draft . pageParams . pop ( ) ;
0 commit comments