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

Perform item reloads in a separate batch of updates #8

Merged
merged 13 commits into from Apr 9, 2024

Conversation

JosephDuffy
Copy link
Collaborator

@JosephDuffy JosephDuffy commented Feb 19, 2024

This works around a bug from ~iOS 14 that causes the last N items in a section to ignore any updates applied to them when N items are deleted from the same section and the items are at the end of the section.

This also removes the conversion of inserts/removals in to updates, which reduces the need to account for these synthesised updates and also more closely matches the intent of the user; if something has truly moved or been updated the appropriate methods can be used, while removals and inserts that happen to result in the same position will not animate as a refresh.

This also fixes the crash that #6 was originally aiming to fix. It became much easier to reason about the changes once the reloads were not synthesised and were using the post-updates index paths. I think this probably fixes some other bugs. At a minimum the existing tests were updated or still passed, plus new tests have been added.

I also created opennetltd/ComposedUITests#1, which adds some more tests to the integration project. These are mostly used to validate that the unit tests here are correct according to UICollectionView, e.g. it does not crash, request any unexpected cells, or fallback to a reloadData.

This works around a bug from ~iOS 14 that causes the last N items in a section to ignore any updates applied to them when N items are deleted from the same section and the items are at the end of the section.

This also removes the conversion of inserts/removals in to updates, which reduces the chances of this code being needed and also more closely matches the intent of the user; if something has truly moved or been updated the appropriate methods can be used, while removals and inserts that happen to result in the same position will not animate as a refresh.
Similar changes made in the `fix-reload-delete-same-index-path` branch, but neither fully pass the new test.
@JosephDuffy
Copy link
Collaborator Author

@MarsOpenNet @NewWay-opennet this is ready for review. If you'd prefer to not review this or know someone else that would be suitable to review this please let me know! I'm not aware of anyone that's particularly familiar with the internals of Composed, but this is quite specific to UICollectionView.

@NewWay-opennet
Copy link

Hi @JosephDuffy , sorry for the late reply. I'll take a look for this.

@JosephDuffy JosephDuffy requested review from ngptsporty and removed request for NewWay-opennet March 13, 2024 09:19
@JosephDuffy JosephDuffy merged commit b429c0f into main Apr 9, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

None yet

3 participants