Skip to content

Commit 5ce639a

Browse files
committed
Fixed collection bug with reoder section.
1 parent 23de80d commit 5ce639a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

SPDiffable.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'SPDiffable'
4-
s.version = '4.0.6'
4+
s.version = '4.0.7'
55
s.summary = 'Extension of Diffable API which allow not duplicate code and use less models. Included example for SideBar.'
66
s.homepage = 'https://github.com/ivanvorobei/SPDiffable'
77
s.source = { :git => 'https://github.com/ivanvorobei/SPDiffable.git', :tag => s.version }

Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ open class SPDiffableCollectionDataSource: NSObject, SPDiffableDataSourceInterfa
239239
let previousSection = sections[previousSectionIndex]
240240
guard let _ = snapshot.sectionIdentifiers.first(where: { $0.id == section.id }) else { continue }
241241
guard let _ = snapshot.sectionIdentifiers.first(where: { $0.id == previousSection.id }) else { continue }
242+
243+
// If try move section to same index as original.
244+
// This line allow skip it action.
245+
// Can happen crash for collection if doing it.
246+
if (previousSectionIndex + 1) == sectionIndex { continue }
247+
242248
snapshot.moveSection(section, afterSection: previousSection)
243249
}
244250

0 commit comments

Comments
 (0)