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

Fix double-load issue with ASCollectionNode #372

Merged
merged 4 commits into from
Jun 19, 2017
Merged

Conversation

Adlai-Holler
Copy link
Member

@Adlai-Holler Adlai-Holler commented Jun 19, 2017

Resolves #351

  • Make [ASCollectionView reloadData*] unavailable, not deprecated. This is breaking API but the methods have been deprecated for going on 7 months.
    • We can't reliably tell the difference between clients calling this method, and UICollectionView itself calling this method, so we can't safely override it and change its behavior.
    • We now unconditionally forward this call to super.
    • It's OK for clients to blindly call reloadData on a view that has been cast to (UICollectionView *) but it just won't do what they expect. Nothing will actually change.
  • Modify [ASCollectionNode reloadData*] to do the real work.
  • Update unit tests.

{
[self.view reloadDataImmediately];
[self.view relayoutItems];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swapped the order of these two methods to group the reloadData* methods together.

} completion:^(BOOL finished){
if (completion) {
completion();
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation copied from ASCollectionView.

Copy link
Member

@nguyenhuy nguyenhuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits aside, LGTM!

{
[self.view reloadDataImmediately];
[self.view relayoutItems];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the original code doesn't assert main thread and check if this node is loaded, should we do these now?

@@ -752,7 +754,8 @@ - (void)testThatSectionContextsAreCorrectAfterReloadData
updateValidationTestPrologue

del.sectionGeneration++;
[cv reloadDataImmediately];
[cn reloadData];
[cn waitUntilAllUpdatesAreCommitted];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because it's deprecated.

UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];\
[window makeKeyAndVisible]; \
window.rootViewController = testController;\
\
[testController.collectionView reloadDataImmediately];\
[cn reloadData];\
[cn waitUntilAllUpdatesAreCommitted]; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, [cn reloadDataImmediately]?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because it's deprecated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it 👍

@@ -259,7 +259,8 @@ - (void)testSelection
[window setRootViewController:testController];
[window makeKeyAndVisible];

[testController.collectionView reloadDataImmediately];
[testController.collectionNode reloadData];
[testController.collectionNode waitUntilAllUpdatesAreCommitted];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we call reloadDataImmediately directly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because it's deprecated.

@Adlai-Holler Adlai-Holler merged commit 3269258 into master Jun 19, 2017
@Adlai-Holler Adlai-Holler deleted the AHFixDoubleReload branch June 19, 2017 21:19
garrettmoon pushed a commit that referenced this pull request Jun 30, 2017
* Fix double-reload issue with ASCollectionNode

* Add a message to the change pile

* Fix some license headers

* Address feedback
bernieperez pushed a commit to AtomTickets/Texture that referenced this pull request Apr 25, 2018
* Fix double-reload issue with ASCollectionNode

* Add a message to the change pile

* Fix some license headers

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

Successfully merging this pull request may close these issues.

2 participants