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

Move section index to property #671

Closed
wants to merge 10 commits into from
Closed

Conversation

amonshiz
Copy link
Contributor

@amonshiz amonshiz commented Apr 18, 2017

Changes in this pull request

This pull request removes the sectionForSectionController: method from the IGListCollectionContext protocol so that the protocol is exclusively for presentation methods.

This should not add new functionality, but rather makes the index directly accessible on the section controllers themselves. This change makes sense because at no time will there be an update to the list that the list adapter is unaware of and so it will always be able to set and update any indexes for a section controller that has changed.

Issue fixed: #609

Checklist

  • All tests pass. Demo project builds and runs.
  • I added tests, an experiment, or detailed why my change isn't tested.
  • I added an entry to the CHANGELOG.md for any breaking changes, enhancements, or bug fixes.
  • I have reviewed the contributing guide

@facebook-github-bot
Copy link
Contributor

@amonshiz updated the pull request - view changes

// [expectation fulfill];
// }];
// [self waitForExpectationsWithTimeout:15 handler:nil];
//}
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

science

XCTAssertEqual(section11.sectionIndex, 0);
XCTAssertEqual(section12.sectionIndex, 0);
XCTAssertEqual(section21.sectionIndex, 1);
XCTAssertEqual(section22.sectionIndex, 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

add more complex cases here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My preference would just be to 86 the stack controller ...

XCTAssertEqual([self.adapter sectionControllerForObject:@3].sectionIndex, 3);
XCTAssertTrue([self.adapter sectionControllerForObject:@3].isLastSection);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

we should probably test: (1) append, (2) insert in middle

@jessesquires
Copy link
Contributor

sectionIndex will always be correct, right? even after ListAdapter mutations?

@jessesquires
Copy link
Contributor

let's make sure we handle the cases that @Adlai-Holler mentioned in the issue

@amonshiz
Copy link
Contributor Author

All the existing tests pass, so at least we have those mutations covered. Would it be worth adding a list adapter mutations specific testing file?

This one test was to cover the case mentioned in the task. However, speaking with Ryan it seems this shouldn't be passing currently so I will need to debug a bit.

@facebook-github-bot
Copy link
Contributor

@amonshiz updated the pull request - view changes

@amonshiz amonshiz force-pushed the move-section-index-to-property branch from 9508684 to e0f6a65 Compare April 19, 2017 15:49
@facebook-github-bot
Copy link
Contributor

@amonshiz updated the pull request - view changes

@@ -38,7 +38,7 @@ IGLK_SUBCLASSING_RESTRICTED
@param objects The objects in the collection.
@param sectionControllers The section controllers that map to each object.
*/
- (void)updateWithObjects:(NSArray <id <NSObject>> *)objects sectionControllers:(NSArray <id <NSObject>> *)sectionControllers;
- (void)updateWithObjects:(NSArray <id <NSObject>> *)objects sectionControllers:(NSArray <IGListSectionController *> *)sectionControllers;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

at some point this method was not updated to the IGListSectionController<IGListSectionType> * type and was missed in a few refactorings. the next method down, sectionControllerForSection: returned an IGListSectionController * so the types were a significant mismatch and needed to be updated.

@@ -23,39 +23,39 @@ @implementation IGListSectionMapTests

- (void)test_whenUpdatingItems_thatArraysAreEqual {
NSArray *objects = @[@0, @1, @2];
NSArray *sectionControllers = @[@"a", @"b", @"c"];
NSArray *sectionControllers = @[[IGListTestSection new], [IGListTestSection new], [IGListTestSection new]];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

all of these are just so that the test actually respects the types that IGListSectionMap require.

@iglistkit-bot
Copy link

iglistkit-bot commented Apr 19, 2017

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

@facebook-github-bot
Copy link
Contributor

@amonshiz updated the pull request - view changes

@jessesquires jessesquires added this to the 3.0.0 milestone Apr 23, 2017
@jessesquires
Copy link
Contributor

@amonshiz -- looks like this is good to go, except for resolving conflicts?

@amonshiz
Copy link
Contributor Author

will do!

@amonshiz amonshiz force-pushed the move-section-index-to-property branch from f489471 to ff5c938 Compare April 24, 2017 22:08
@facebook-github-bot
Copy link
Contributor

@amonshiz updated the pull request - view changes

@facebook-github-bot
Copy link
Contributor

@amonshiz has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@amonshiz updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@amonshiz has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

…eplace with sectionIndex property on IGListSectionController.
- Tests pass
- Used Xcode 8.3, not sure if that impacts changes in `project.pbxproj` files.
… inserting at beginning.

Also, tests `isFirstSection` and `isLastSection` across a head insert.
@amonshiz amonshiz force-pushed the move-section-index-to-property branch from 0dc49b6 to fd78480 Compare April 28, 2017 18:54
@facebook-github-bot
Copy link
Contributor

@amonshiz updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@amonshiz has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@rnystrom rnystrom mentioned this pull request May 1, 2017
15 tasks
@amonshiz amonshiz mentioned this pull request May 1, 2017
2 tasks
@jessesquires jessesquires deleted the move-section-index-to-property branch May 1, 2017 17:39
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.

RFC: Add section property to IGListSectionController
4 participants