getImagesForIds return array will now keep the same order of images id array input
This commit is contained in:
parent
0f1e1f02f6
commit
cd0af65728
|
@ -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];
|
||||
|
|
Loading…
Reference in New Issue