Add production workaround for missing elements (#3158)

This commit is contained in:
Adlai Holler
2017-03-10 06:35:20 -08:00
committed by Huy Nguyen
parent a0e67a8b15
commit bfe35fc0b1
2 changed files with 27 additions and 3 deletions

View File

@@ -1740,14 +1740,22 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
// Visible items
for (NSIndexPath *indexPath in self.indexPathsForVisibleItems) {
ASCollectionElement *element = [map elementForItemAtIndexPath:indexPath];
[result addObject:element];
if (element != nil) {
[result addObject:element];
} else {
ASDisplayNodeFailAssert(@"Couldn't find 'visible' item at index path %@ in map %@", indexPath, map);
}
}
// Visible supplementary elements
for (NSString *kind in map.supplementaryElementKinds) {
for (NSIndexPath *indexPath in [self asdk_indexPathsForVisibleSupplementaryElementsOfKind:kind]) {
ASCollectionElement *element = [map supplementaryElementOfKind:kind atIndexPath:indexPath];
[result addObject:element];
if (element != nil) {
[result addObject:element];
} else {
ASDisplayNodeFailAssert(@"Couldn't find 'visible' supplementary element of kind %@ at index path %@ in map %@", kind, indexPath, map);
}
}
}
return result;