ListOverlay: don't loop through all items if we just want 2
`map` does not short-circuit
This commit is contained in:
parent
5b2c901496
commit
2e3f9f94ce
1 changed files with 7 additions and 10 deletions
|
@ -25,20 +25,17 @@ function CollectionPreviewOverlay(props: Props) {
|
||||||
}, [collectionId, collectionItemUrls, fetchCollectionItems]);
|
}, [collectionId, collectionItemUrls, fetchCollectionItems]);
|
||||||
|
|
||||||
if (collectionItemUrls && collectionItemUrls.length > 0) {
|
if (collectionItemUrls && collectionItemUrls.length > 0) {
|
||||||
|
const displayed = collectionItemUrls.slice(0, 2);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="collection-preview__overlay-thumbs">
|
<div className="collection-preview__overlay-thumbs">
|
||||||
<div className="collection-preview__overlay-side" />
|
<div className="collection-preview__overlay-side" />
|
||||||
<div className="collection-preview__overlay-grid">
|
<div className="collection-preview__overlay-grid">
|
||||||
{collectionItemUrls &&
|
{displayed.map((uri) => (
|
||||||
collectionItemUrls.map((item, index) => {
|
<div className="collection-preview__overlay-grid-items" key={uri}>
|
||||||
if (index < 2) {
|
<FileThumbnail uri={uri} />
|
||||||
return (
|
</div>
|
||||||
<div className="collection-preview__overlay-grid-items" key={item}>
|
))}
|
||||||
<FileThumbnail uri={item} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
})}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue