Skip to content

Commit

Permalink
Fixed collection bug with reoder section.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanvorobei committed Feb 23, 2022
1 parent 23de80d commit 5ce639a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion SPDiffable.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'SPDiffable'
s.version = '4.0.6'
s.version = '4.0.7'
s.summary = 'Extension of Diffable API which allow not duplicate code and use less models. Included example for SideBar.'
s.homepage = 'https://github.com/ivanvorobei/SPDiffable'
s.source = { :git => 'https://github.com/ivanvorobei/SPDiffable.git', :tag => s.version }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ open class SPDiffableCollectionDataSource: NSObject, SPDiffableDataSourceInterfa
let previousSection = sections[previousSectionIndex]
guard let _ = snapshot.sectionIdentifiers.first(where: { $0.id == section.id }) else { continue }
guard let _ = snapshot.sectionIdentifiers.first(where: { $0.id == previousSection.id }) else { continue }

// If try move section to same index as original.
// This line allow skip it action.
// Can happen crash for collection if doing it.
if (previousSectionIndex + 1) == sectionIndex { continue }

snapshot.moveSection(section, afterSection: previousSection)
}

Expand Down

0 comments on commit 5ce639a

Please sign in to comment.