Skip to content

Commit

Permalink
Fix process change when itemMove is present
Browse files Browse the repository at this point in the history
Fixing order of ChangeItem when applying if there is an itemMove and itemInsert in the same section
  • Loading branch information
Aranoledur committed Sep 18, 2023
1 parent 52481e1 commit 84e658b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ChatLayout/Classes/Core/Model/ChangeItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ extension ChangeItem: Comparable {
} else {
return lInitialSectionIndex < rInitialSectionIndex
}
case let (.itemMove(initialItemIndexPath: lInitialIndexPath, finalItemIndexPath: lFinalIndexPath),
.itemMove(initialItemIndexPath: rInitialIndexPath, finalItemIndexPath: rFinalIndexPath)):
if lInitialIndexPath == rInitialIndexPath {
return lFinalIndexPath < rFinalIndexPath
} else {
return lInitialIndexPath < rInitialIndexPath
}
case let (.itemMove(initialItemIndexPath: _, finalItemIndexPath: lFinalIndexPath),
.itemMove(initialItemIndexPath: _, finalItemIndexPath: rFinalIndexPath)):
return lFinalIndexPath < rFinalIndexPath
case let (.itemInsert(itemIndexPath: lIndexPath), .itemMove(initialItemIndexPath: _, finalItemIndexPath: rfinalItemIndexPath)):
return lIndexPath < rfinalItemIndexPath
case let (.itemMove(initialItemIndexPath: _, finalItemIndexPath: lfinalItemIndexPath), .itemInsert(itemIndexPath: rIndexPath)):
return lfinalItemIndexPath < rIndexPath
default:
return lhs.rawValue < rhs.rawValue
}
Expand Down

0 comments on commit 84e658b

Please sign in to comment.