Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TableSection isContentEqual implementation forces the algorithm to reload whole section on insertion #45

Open
andriigua opened this issue Dec 11, 2019 · 0 comments

Comments

@andriigua
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant