diff --git a/README.md b/README.md index 909c79d..8ea53f3 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ This minimum supported version is iOS 11.0

Importing With SwiftPM


-https://github.com/scribd/LiveCollections 1.0.2 +https://github.com/scribd/LiveCollections 1.0.3

@@ -36,7 +36,7 @@ https://github.com/scribd/LiveCollections 1.0.2

Importing With Carthage


-github "scribd/LiveCollections" "1.0.2" +github "scribd/LiveCollections" "1.0.3"

@@ -44,7 +44,7 @@ github "scribd/LiveCollections" "1.0.2"

Importing With CocoaPods


-pod 'LiveCollections', '~> 1.0.2' +pod 'LiveCollections', '~> 1.0.3'
or
diff --git a/Sources/LiveCollections/Classes/Internal/ItemDataCalculator.swift b/Sources/LiveCollections/Classes/Internal/ItemDataCalculator.swift index b9ea549..bd0b70f 100644 --- a/Sources/LiveCollections/Classes/Internal/ItemDataCalculator.swift +++ b/Sources/LiveCollections/Classes/Internal/ItemDataCalculator.swift @@ -205,13 +205,7 @@ private extension ItemDataCalculator { self?._performNextCalculation() } - let isDeltaAccurate: Bool = (itemProvider.items.count + delta.insertions.count - delta.deletions.count) == updatedItems.count - - if isDeltaAccurate == false { - calculationDelegate?.inaccurateDeltaDetected(delta) - } - - guard delta.hasChanges, isDeltaAccurate else { + guard delta.hasChanges else { updateData() calculationCompletion() return @@ -228,8 +222,13 @@ private extension ItemDataCalculator { targetView.reloadData() } + let isDeltaInaccurate: Bool = (itemProvider.items.count + delta.insertions.count - delta.deletions.count) != updatedItems.count + if isDeltaInaccurate { + self.calculationDelegate?.inaccurateDeltaDetected(delta) + } + let itemAnimationStlye: AnimationStyle = { - if targetView.frame.isEmpty { return .reloadData } + if targetView.frame.isEmpty || isDeltaInaccurate { return .reloadData } guard let animationDelegate = animationDelegate else { return .preciseAnimations } return animationDelegate.preferredItemAnimationStyle(for: delta) }() diff --git a/Sources/LiveCollections/Classes/Internal/SectionDataCalculator.swift b/Sources/LiveCollections/Classes/Internal/SectionDataCalculator.swift index 172bf5e..ef3af38 100644 --- a/Sources/LiveCollections/Classes/Internal/SectionDataCalculator.swift +++ b/Sources/LiveCollections/Classes/Internal/SectionDataCalculator.swift @@ -277,13 +277,8 @@ private extension SectionDataCalculator { let currentItemCount: Int = sectionProvider.sections.reduce(0) { $0 + $1.items.count } let updatedItemCount: Int = updatedSections.reduce(0) { $0 + $1.items.count } - let isDeltaAccurate: Bool = (currentItemCount + itemDelta.insertions.count - itemDelta.deletions.count) == updatedItemCount - if isDeltaAccurate == false { - self.calculationDelegate?.inaccurateDeltaDetected(itemDelta) - } - - guard (sectionDelta.hasChanges || itemDelta.hasChanges), isDeltaAccurate else { + guard sectionDelta.hasChanges || itemDelta.hasChanges else { sectionProvider.calculatingSections = nil calculationCompletion() return // don't need to update with no changes @@ -310,8 +305,13 @@ private extension SectionDataCalculator { return } + let isDeltaInaccurate: Bool = (currentItemCount + itemDelta.insertions.count - itemDelta.deletions.count) != updatedItemCount + if isDeltaInaccurate { + self.calculationDelegate?.inaccurateDeltaDetected(itemDelta) + } + let itemAnimationStlye: AnimationStyle = { - if view.frame.isEmpty { return .reloadData } + if view.frame.isEmpty || isDeltaInaccurate { return .reloadData } guard let animationDelegate = animationDelegate else { return .preciseAnimations } return animationDelegate.preferredItemAnimationStyle(for: itemDelta) }()