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 {
204204 }
205205 self ? . _performNextCalculation ( )
206206 }
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 {
209215 updateData ( )
210216 calculationCompletion ( )
211217 return
Original file line number Diff line number Diff line change @@ -274,8 +274,16 @@ private extension SectionDataCalculator {
274274 }
275275 return
276276 }
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 {
279287 sectionProvider. calculatingSections = nil
280288 calculationCompletion ( )
281289 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 {
6565
6666 func collectionDataDidBeginCalculating( )
6767 func collectionDataDidEndCalculating( )
68+ func inaccurateDeltaDetected( _ delta: IndexDelta )
6869}
6970
7071// MARK: CollectionDataAnimationDelegate
You can’t perform that action at this time.
0 commit comments