File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed
Sources/LiveCollections/Classes Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -204,8 +204,14 @@ private extension ItemDataCalculator {
204
204
}
205
205
self ? . _performNextCalculation ( )
206
206
}
207
-
208
- guard delta. hasChanges else {
207
+
208
+ let isDeltaAccurate : Bool = ( itemProvider. items. count + delta. insertions. count - delta. deletions. count) == updatedItems. count
209
+
210
+ if isDeltaAccurate == false {
211
+ calculationDelegate? . inaccurateDeltaDetected ( delta)
212
+ }
213
+
214
+ guard delta. hasChanges, isDeltaAccurate else {
209
215
updateData ( )
210
216
calculationCompletion ( )
211
217
return
Original file line number Diff line number Diff line change @@ -274,8 +274,16 @@ private extension SectionDataCalculator {
274
274
}
275
275
return
276
276
}
277
-
278
- guard sectionDelta. hasChanges || itemDelta. hasChanges else {
277
+
278
+ let currentItemCount : Int = sectionProvider. sections. reduce ( 0 ) { $0 + $1. items. count }
279
+ let updatedItemCount : Int = updatedSections. reduce ( 0 ) { $0 + $1. items. count }
280
+ let isDeltaAccurate : Bool = ( currentItemCount + itemDelta. insertions. count - itemDelta. deletions. count) == updatedItemCount
281
+
282
+ if isDeltaAccurate == false {
283
+ self . calculationDelegate? . inaccurateDeltaDetected ( itemDelta)
284
+ }
285
+
286
+ guard ( sectionDelta. hasChanges || itemDelta. hasChanges) , isDeltaAccurate else {
279
287
sectionProvider. calculatingSections = nil
280
288
calculationCompletion ( )
281
289
return // don't need to update with no changes
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ public protocol CollectionDataCalculationNotificationDelegate: AnyObject {
65
65
66
66
func collectionDataDidBeginCalculating( )
67
67
func collectionDataDidEndCalculating( )
68
+ func inaccurateDeltaDetected( _ delta: IndexDelta )
68
69
}
69
70
70
71
// MARK: CollectionDataAnimationDelegate
You can’t perform that action at this time.
0 commit comments