File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
66#### Master
77
88* Added support of mutable CellViewModels.
9+ * Fixes failing duplicate identity detection
910
1011## [ 4.0.1] ( https://github.com/RxSwiftCommunity/RxDataSources/releases/tag/4.0.1 )
1112
Original file line number Diff line number Diff line change @@ -199,11 +199,19 @@ public enum Diff {
199199 dictionary [ key] = i
200200 }
201201
202+ var finalKeys = Set < OptimizedIdentity < Identity > > ( )
203+
202204 for (i, items) in finalItemCache. enumerated ( ) {
203205 for j in 0 ..< items. count {
204206 let item = items [ j]
205207 var identity = item. identity
206208 let key = OptimizedIdentity ( & identity)
209+
210+ if finalKeys. contains ( key) {
211+ throw Error . duplicateItem ( item: item)
212+ }
213+ finalKeys. insert ( key)
214+
207215 guard let initialItemPathIndex = dictionary [ key] else {
208216 continue
209217 }
@@ -518,8 +526,16 @@ public enum Diff {
518526 var initialSectionData = ContiguousArray < SectionAssociatedData > ( repeating: SectionAssociatedData . initial, count: initialSections. count)
519527 var finalSectionData = ContiguousArray < SectionAssociatedData > ( repeating: SectionAssociatedData . initial, count: finalSections. count)
520528
529+ var finalSectionIdentities = Set < Section . Identity > ( )
530+
521531 for (i, section) in finalSections. enumerated ( ) {
522532 finalSectionData [ i] . itemCount = finalSections [ i] . items. count
533+
534+ if finalSectionIdentities. contains ( section. identity) {
535+ throw Error . duplicateSection ( section: section)
536+ }
537+ finalSectionIdentities. insert ( section. identity)
538+
523539 guard let initialSectionIndex = initialSectionIndexes [ section. identity] else {
524540 continue
525541 }
You can’t perform that action at this time.
0 commit comments