-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 images being out of order in ShareDialog #2468
Fix images being out of order in ShareDialog #2468
Conversation
Hi @sebastiangrail! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign 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 to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
@yuriy-tolstoguzov has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@yuriy-tolstoguzov merged this pull request in 5141366. |
Thank you for the fix @sebastiangrail ! |
Summary: - [x] sign [contributor license agreement](https://code.facebook.com/cla) (signed by company) - [x] I've ensured that all existing tests pass and added tests (when/where necessary) - [x] I've updated the documentation (when/where necessary) and [Changelog](CHANGELOG.md) (when/where necessary) - [ ] I've added the proper label to this pull request (e.g. `bug` for bug fixes) ## Pull Request Details When sharing multiple images their order is not stable: ```Swift let content = SharePhotoContent() content.photos = imagePaths let dialog = ShareDialog(viewController: presenter, content: content, delegate: delegate) try dialog.validate() dialog.show() ``` This is because they are uniqued by converting into a `Set` and back to an `Array`: ``` let uniqueImages = Set(photoContent.photos.compactMap(\.image)) return Array(uniqueImages) ``` This PR ensures that the original order is preserved by using an `Array.filter` with an auxiliary `Set` to keep the performance `O(n)`. Pull Request resolved: #2468 Test Plan: Uniquing is done in a private property and is currently not covered by tests. Reviewed By: caodoan Differential Revision: D61862742 Pulled By: yuriy-tolstoguzov fbshipit-source-id: 36878263588dade8c56e7bc79ffdabb35af9e7ab
bug
for bug fixes)Pull Request Details
When sharing multiple images their order is not stable:
This is because they are uniqued by converting into a
Set
and back to anArray
:This PR ensures that the original order is preserved by using an
Array.filter
with an auxiliarySet
to keep the performanceO(n)
.Test Plan
Uniquing is done in a private property and is currently not covered by tests.