@@ -220,21 +220,7 @@ open class MessagesViewController: UIViewController, UICollectionViewDelegateFlo
220220 snapshot. appendItems ( [ . init( kind: . typingIndicator) ] )
221221 }
222222
223- var oldSnapshot = diffableDataSource. snapshot ( )
224- let oldItems = Set ( oldSnapshot. itemIdentifiers)
225- let newItems = Set ( snapshot. itemIdentifiers)
226-
227- let unchangedItems = oldItems. intersection ( newItems)
228- // If we have the exact same item identifiers then there is no need to do a full reload - we apply old snapshot
229- // with only reloading items that have changed
230- if oldSnapshot. itemIdentifiers == snapshot. itemIdentifiers {
231- reloadUnchangedItems ( on: & oldSnapshot, unchangedItems: unchangedItems, newItems: newItems)
232- diffableDataSource. apply ( oldSnapshot, animatingDifferences: animated, completion: internalCompletion)
233- } else {
234- reloadUnchangedItems ( on: & snapshot, unchangedItems: unchangedItems, newItems: newItems)
235- // Order of the items has changed - we only apply new snapshot
236- diffableDataSource. apply ( snapshot, animatingDifferences: animated, completion: internalCompletion)
237- }
223+ diffableDataSource. apply ( snapshot, animatingDifferences: animated, completion: internalCompletion)
238224 }
239225
240226 func reloadUnchangedItems( on snapshot: inout NSDiffableDataSourceSnapshot < Int , Entry > , unchangedItems: Set < Entry > , newItems: Set < Entry > ) {
@@ -530,6 +516,7 @@ internal struct Entry: Hashable, @unchecked Sendable {
530516 switch kind {
531517 case . message( let message) :
532518 hasher. combine ( message. messageId)
519+ hasher. combine ( message. hash)
533520 case . typingIndicator:
534521 hasher. combine ( " typingIndicator " )
535522 }
@@ -547,7 +534,7 @@ internal struct Entry: Hashable, @unchecked Sendable {
547534 static func == ( lhs: Entry , rhs: Entry ) -> Bool {
548535 switch ( lhs. kind, rhs. kind) {
549536 case ( . message( let lhs) , . message( let rhs) ) :
550- return lhs. messageId == rhs. messageId
537+ return lhs. messageId == rhs. messageId && lhs . hash == rhs . hash
551538 case ( . typingIndicator, . typingIndicator) :
552539 return true
553540 default :
0 commit comments