Permalink
Browse files

iOS: Fix CameraRoll to support custom user groups

Summary:
on iOS, if you pull photo from one of user's custom album, the app crashes on the assertion `RCTAssert(resolvedPromise == NO, @"Resolved the promise before we finished processing the results.");` . assertion that was assumed to never been reached.

According to iOS doc, the enumerateGroupsWithTypes `usingBlock` block is called with `group=nil` when the iteration is over, but in current react-native implementation, it is stopping in other circumstance (because the `else` case) which is probably a mistake.

You have probably never seen the bug because you didn't tried to use getPhotos with something else than the pre-defined groups, but it should be possible to do so *(and it seems to work fine as soon as I included my fix. Later I should provide a PR that includes a way to list user groups :) but at least I need this to gets in, otherwise it crashes)*.

For instance, User have a Photo Folder (or "album", whatever you call it) called "Instagram", when I call `CameraRoll.getPhotos({ groupName: "Instagram",
Closes #10272

Differential Revision: D4009342

Pulled By: javache

fbshipit-source-id: a73ca828133b4f0d880c229f9b675538854020de
  • Loading branch information...
1 parent 8802db3 commit 0010df514e3fc19ea182c7f472b4f19779434ae5 @gre gre committed with Facebook Github Bot Oct 12, 2016
Showing with 3 additions and 1 deletion.
  1. +3 −1 Libraries/CameraRoll/RCTCameraRollManager.m
@@ -209,7 +209,9 @@ static void RCTResolvePromise(RCTPromiseResolveBlock resolve,
}];
}
}];
- } else {
+ }
+
+ if (!group) {
// Sometimes the enumeration continues even if we set stop above, so we guard against resolving the promise
// multiple times here.
if (!resolvedPromise) {

0 comments on commit 0010df5

Please sign in to comment.