-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add -[IGListAdapter objectForSectionController:] helper method -- iss… #204
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small update on the assert, and it looks like it might need a rebase (some conflicts).
Thanks for knocking this out so quickly! Issue wasn't even open for an hour 🙏
adjustForUpdateBlock:NO]; | ||
NSArray *paths0 = [self.adapter indexPathsFromSectionController:second | ||
indexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(2, 4)] | ||
adjustForUpdateBlock:NO]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
IGAssertMainThread(); | ||
IGParameterAssert(sectionController != nil); | ||
|
||
NSUInteger section = [self.sectionMap sectionForSectionController:sectionController]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: const
IGParameterAssert(sectionController != nil); | ||
|
||
NSUInteger section = [self.sectionMap sectionForSectionController:sectionController]; | ||
IGAssert(section != NSNotFound, @"Section nil for section controller %@", sectionController); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm if this assert will be too aggressive. Sometimes weird things happen and its probably ok to return nil
in that case (for instance, the -[IGListSectionMap objectForSection:]
method actually returns nil
if the section is OOB).
I think we should probably omit this assert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I based this off the implementation for -[IGListAdapter objectAtSection:]
, which crashes if you pass in an index that's out of bounds. The assert I wrote actually wouldn't work, but there definitely needs to be a bounds check.
I'm assuming that's another issue that should be fixed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@saraswatayu that method should have been updated (source here) so it doesn't assert.
Are you looking at the stable
branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhh I see your commit on the SectionMap! I didn't realize my earlier rebase to my fork didn't quite work as expected; I'll update this real quick.
@saraswatayu -- Please add this to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's some doc nits, too 😊
@@ -137,6 +137,15 @@ IGLK_SUBCLASSING_RESTRICTED | |||
- (__kindof IGListSectionController <IGListSectionType> * _Nullable)sectionControllerForObject:(id)object; | |||
|
|||
/** | |||
Fetch the object corresponding to a list in the feed. Constant time lookup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, let's say:
Returns the object corresponding to the specified section controller in the list. Constant time lookup.
@@ -137,6 +137,15 @@ IGLK_SUBCLASSING_RESTRICTED | |||
- (__kindof IGListSectionController <IGListSectionType> * _Nullable)sectionControllerForObject:(id)object; | |||
|
|||
/** | |||
Fetch the object corresponding to a list in the feed. Constant time lookup. | |||
|
|||
@param sectionController A list object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@param sectionController A section controller in the list.
|
||
@param sectionController A list object. | ||
|
||
@return An object or nil. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@return The object for the specified section controller, or
nil
if not found.
3f48a1f
to
e912565
Compare
@saraswatayu updated the pull request - view changes |
@jessesquires @rnystrom Thanks for your comments! It should now be updated - let me know if there's something else that catches your eye. 😄 |
@rnystrom has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Changes in this pull request
Add -[IGListAdapter objectForSectionController:] helper method
Fixes #201
Pull request checklist