-
-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Hi @malcommac
I've started to use TableDirector for rendering some parts of the content in my app and noticed really strange behavior - if you do an insertion into TableSection the whole section gets refreshed. Because this was not happening for CollectionDirector, I've started to look into your algorithm and it appeared that for TableSection the implementation of isContentEqual is different and I believe is incorrect - instead of just comparing identifiers the implementation also looks into the content itself which actually forces DifferenceKit based algorithm to reload the whole section instead of simply do the insertion:
TableSection
public func isContentEqual(to other: Differentiable) -> Bool {
guard let other = other as? TableSection,
elements.count == other.elements.count else {
return false
}
for item in elements.enumerated() {
if item.element.isContentEqual(to: other.elements[item.offset]) == false {
return false
}
}
return true
}
CollectionSection
public func isContentEqual(to other: Differentiable) -> Bool {
guard let other = other as? CollectionSection else {
return false
}
return self.identifier == other.identifier
}
I did some fast tests and when I've changed the implementation of isContentEqual to the same as for CollectionSection, everything started to work better. Unfortunately, as the method is marked as public and not open I am not able to resolve this issue without your help.
Could you please do this small change in order to fix the bug?