File tree Expand file tree Collapse file tree 2 files changed +14
-15
lines changed
Sources/LiveCollections/Classes/Internal Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -205,13 +205,7 @@ private extension ItemDataCalculator {
205205 self ? . _performNextCalculation ( )
206206 }
207207
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 {
208+ guard delta. hasChanges else {
215209 updateData ( )
216210 calculationCompletion ( )
217211 return
@@ -228,8 +222,13 @@ private extension ItemDataCalculator {
228222 targetView. reloadData ( )
229223 }
230224
225+ let isDeltaInaccurate : Bool = ( itemProvider. items. count + delta. insertions. count - delta. deletions. count) != updatedItems. count
226+ if isDeltaInaccurate {
227+ self . calculationDelegate? . inaccurateDeltaDetected ( delta)
228+ }
229+
231230 let itemAnimationStlye : AnimationStyle = {
232- if targetView. frame. isEmpty { return . reloadData }
231+ if targetView. frame. isEmpty || isDeltaInaccurate { return . reloadData }
233232 guard let animationDelegate = animationDelegate else { return . preciseAnimations }
234233 return animationDelegate. preferredItemAnimationStyle ( for: delta)
235234 } ( )
Original file line number Diff line number Diff line change @@ -277,13 +277,8 @@ private extension SectionDataCalculator {
277277
278278 let currentItemCount : Int = sectionProvider. sections. reduce ( 0 ) { $0 + $1. items. count }
279279 let updatedItemCount : Int = updatedSections. reduce ( 0 ) { $0 + $1. items. count }
280- let isDeltaAccurate : Bool = ( currentItemCount + itemDelta. insertions. count - itemDelta. deletions. count) == updatedItemCount
281280
282- if isDeltaAccurate == false {
283- self . calculationDelegate? . inaccurateDeltaDetected ( itemDelta)
284- }
285-
286- guard ( sectionDelta. hasChanges || itemDelta. hasChanges) , isDeltaAccurate else {
281+ guard sectionDelta. hasChanges || itemDelta. hasChanges else {
287282 sectionProvider. calculatingSections = nil
288283 calculationCompletion ( )
289284 return // don't need to update with no changes
@@ -310,8 +305,13 @@ private extension SectionDataCalculator {
310305 return
311306 }
312307
308+ let isDeltaInaccurate : Bool = ( currentItemCount + itemDelta. insertions. count - itemDelta. deletions. count) != updatedItemCount
309+ if isDeltaInaccurate {
310+ self . calculationDelegate? . inaccurateDeltaDetected ( itemDelta)
311+ }
312+
313313 let itemAnimationStlye : AnimationStyle = {
314- if view. frame. isEmpty { return . reloadData }
314+ if view. frame. isEmpty || isDeltaInaccurate { return . reloadData }
315315 guard let animationDelegate = animationDelegate else { return . preciseAnimations }
316316 return animationDelegate. preferredItemAnimationStyle ( for: itemDelta)
317317 } ( )
You can’t perform that action at this time.
0 commit comments