@@ -559,8 +559,6 @@ final class StateController<Layout: ChatLayoutRepresentation> {
559
559
560
560
reloadedSectionsIndexesArray. append ( sectionIndex)
561
561
case let . itemReload( itemIndexPath: indexPath) :
562
- reloadedIndexes. insert ( indexPath)
563
-
564
562
reloadedItemsIndexesArray. append ( indexPath)
565
563
case let . itemReconfigure( itemIndexPath: indexPath) :
566
564
reconfiguredItemsIndexesArray. append ( indexPath)
@@ -741,18 +739,6 @@ final class StateController<Layout: ChatLayoutRepresentation> {
741
739
}
742
740
}
743
741
744
- for indexPath in reloadedItemsIndexesArray {
745
- guard var item = item ( for: indexPath. itemPath, kind: . cell, at: . beforeUpdate) else {
746
- assertionFailure ( " Item at index path ( \( indexPath. section) - \( indexPath. item) ) does not exist. " )
747
- continue
748
- }
749
- let oldHeight = item. frame. height
750
- let configuration = layoutRepresentation. configuration ( for: . cell, at: indexPath)
751
- applyConfiguration ( configuration, to: & item)
752
- afterUpdateModel. replaceItem ( item, at: indexPath)
753
- visibleBoundsBeforeUpdate. offsettingBy ( dx: 0 , dy: item. frame. height - oldHeight)
754
- }
755
-
756
742
for indexPath in deletedItemsIndexesArray {
757
743
guard let itemId = itemIdentifier ( for: indexPath. itemPath, kind: . cell, at: . beforeUpdate) else {
758
744
assertionFailure ( " Item at index path ( \( indexPath. section) - \( indexPath. item) ) does not exist. " )
@@ -795,6 +781,20 @@ final class StateController<Layout: ChatLayoutRepresentation> {
795
781
}
796
782
}
797
783
784
+ for indexPath in reloadedItemsIndexesArray {
785
+ guard var item = item ( for: indexPath. itemPath, kind: . cell, at: . beforeUpdate) ,
786
+ let indexPathAfterUpdate = afterUpdateModel. itemPath ( by: item. id, kind: . cell) ? . indexPath else {
787
+ assertionFailure ( " Item at index path ( \( indexPath. section) - \( indexPath. item) ) does not exist. " )
788
+ continue
789
+ }
790
+ reloadedIndexes. insert ( indexPathAfterUpdate)
791
+ let oldHeight = item. frame. height
792
+ let configuration = layoutRepresentation. configuration ( for: . cell, at: indexPathAfterUpdate)
793
+ applyConfiguration ( configuration, to: & item)
794
+ afterUpdateModel. replaceItem ( item, at: indexPathAfterUpdate)
795
+ visibleBoundsBeforeUpdate. offsettingBy ( dx: 0 , dy: item. frame. height - oldHeight)
796
+ }
797
+
798
798
for indexPath in reconfiguredItemsIndexesArray {
799
799
guard var item = item ( for: indexPath. itemPath, kind: . cell, at: . beforeUpdate) ,
800
800
let indexPathAfterUpdate = afterUpdateModel. itemPath ( by: item. id, kind: . cell) ? . indexPath else {
0 commit comments