getImagesForIds return array will now keep the same order of images id array input

This commit is contained in:
Ran Greenberg 2016-10-20 16:36:44 +03:00
parent 0f1e1f02f6
commit cd0af65728
1 changed files with 19 additions and 9 deletions

View File

@ -194,7 +194,7 @@ RCT_EXPORT_METHOD(getImagesForIds:(NSArray*)imagesIdArray
resolve:(RCTPromiseResolveBlock)resolve
reject:(__unused RCTPromiseRejectBlock)reject) {
NSMutableArray *assetsArray = [[NSMutableArray alloc] init];
NSMutableArray *assetsArray = [[NSMutableArray alloc] initWithArray:imagesIdArray];
PHImageRequestOptions *imageRequestOptions = [[PHImageRequestOptions alloc] init];
imageRequestOptions.synchronous = YES;
@ -208,20 +208,30 @@ RCT_EXPORT_METHOD(getImagesForIds:(NSArray*)imagesIdArray
if (assetInfoDict && assetInfoDict[@"uri"] && assetInfoDict[@"size"] && assetInfoDict[@"name"] && assetLocalId) {
NSUInteger originalArrayIndex = [imagesIdArray indexOfObject:assetLocalId];
[assetsArray addObject:@{@"uri": assetInfoDict[@"uri"],
[assetsArray replaceObjectAtIndex:originalArrayIndex withObject:@{@"uri": assetInfoDict[@"uri"],
@"size": assetInfoDict[@"size"],
@"name": assetInfoDict[@"name"],
@"id": assetLocalId}];
}
}
NSMutableArray *resolveArray = [NSMutableArray new];
for (id obj in assetsArray) {
if ([obj isKindOfClass:[NSDictionary class]]) {
[resolveArray addObject:obj];
}
}
if (resolve) {
resolve(@{@"images": assetsArray});
resolve(@{@"images": resolveArray});
}
}
RCT_EXPORT_METHOD(checkDevicePhotosAuthorizationStatus:(RCTPromiseResolveBlock)resolve
reject:(__unused RCTPromiseRejectBlock)reject) {
NSNumber *status = [CKGalleryManager checkDeviceGalleryAuthorizationStatus];