-
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
Make sure collection have unique ListDiffable objects on initial data… #993
Conversation
… source setup too
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Not sure about logic behind this test, when started separately looks like it always fails IGListKit/Tests/IGListDebuggerTests.m Line 48 in a6f264f
|
Actually throw on removed test "test_whenPassingNonUniqueIdentifiers_adapterShouldAssert" make extra one description hanging around
Source/IGListAdapter.m
Outdated
} | ||
#endif | ||
|
||
NSArray *uniqueObjects = objectsWithDuplicateIdentifiersRemoved(objects); |
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.
While not opposed to this change, this does make deduping in the updater redundant.
Maybe instead the deduping should be done here:
https://github.com/Instagram/IGListKit/blob/master/Source/IGListAdapter.m#L146
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.
@rnystrom If I dedupe at https://github.com/Instagram/IGListKit/blob/master/Source/IGListAdapter.m#L146 we still have the same issue reappear on reloadDataWithCompletion for adapter:
IGListKit/Source/IGListAdapter.m
Line 368 in b3ffafc
[weakSelf updateObjects:newItems dataSource:dataSource]; |
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.
Oooooooh, now I see it! Wo this is an awesome find @yemodin! How about we:
- Move the dedupe to public settings change and reloadData
- We make a followup issue to consolidate and dedupe in one place
I actually want to move object generation entirely so that "to" object arrays are only constructed once. Atm they are built w/ every call to performUpdatesAnimated:completion:
, even if a bunch of calls are updated into a single batch.
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.
Done. Also made deduping before performUpdatesAnimated
IGListKit/Source/IGListAdapter.m
Line 322 in b3ffafc
NSArray *newObjects = [dataSource objectsForListAdapter:self]; |
And test for such case.
Added test for updates
@yemodin would love to import this, but we still need you to sign the CLA, then we're good to go! https://code.facebook.com/cla |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Source/IGListAdapter.m
Outdated
@@ -319,14 +321,14 @@ - (void)performUpdatesAnimated:(BOOL)animated completion:(IGListUpdaterCompletio | |||
} | |||
|
|||
NSArray *fromObjects = self.sectionMap.objects; | |||
NSArray *newObjects = [dataSource objectsForListAdapter:self]; | |||
NSArray *uniqueObjects = objectsWithDuplicateIdentifiersRemoved([dataSource objectsForListAdapter:self]); |
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.
If we're going to put this here (which we don't need to yet), we should remove it from here since that'll be wasteful. I lean towards not messing w/ it here since it'll be extra work (dedupe every update call instead of at coalescence).
I'm actually going to patch that change then import this!
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.
@rnystrom has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Internal CI is reporting a test failure for |
@rnystrom It fails because "revert dedupe in performUpdatesAnimated". If only set objects twice and perform update on adapter it will pass duplicates too |
Is this pull request going to be merged to |
@rnystrom Should I return dedupe to performUpdatesAnimated? Let me know if we have better options. |
Nope, this PR adds deduping to a few places where it was missing and causing inconsistencies. The assert is staying put tho as a warning to the developer that the data you're putting into IGLK isn't what you're going to see. |
Need to unland and re-evaluate, this caused some regressions internally |
False alarm, something else started crashing in a similar spot at almost the exact same time. Will be reverting my revert this week 😅 |
Summary: … source setup too Issue fixed: #815 - [x] All tests pass. Demo project builds and runs. - [x] I added tests, an experiment, or detailed why my change isn't tested. - [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes. - [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md) Closes #993 Reviewed By: manicakes Differential Revision: D6388270 Pulled By: rnystrom fbshipit-source-id: e5e7e047bad5f21b81b562ebd586f7f5036325ff
@rnystrom -- re-opened this so we don't loose track. close once you successfully un-revert? 😄 |
Added in c7d4dc2 |
… source setup too
Changes in this pull request
Issue fixed: #815
Checklist
CHANGELOG.md
for any breaking changes, enhancements, or bug fixes.