const accountId = context.accountId; const likesByUsers = props.likesByUsers || {}; const limit = props.limit ?? 3; let likes = Object.keys(likesByUsers).reverse(); const graphLikes = []; const nonGraph = []; const graph = (accountId && Social.keys(`${accountId}/graph/follow/*`, "final")[accountId].graph .follow) || {}; likes.forEach((accountId) => { if (accountId in graph) { graphLikes.push(accountId); } else { nonGraph.push(accountId); } }); let faces = [...graphLikes, ...nonGraph]; if (faces.length < limit + 3) { limit = faces.length; } const renderFaces = faces.splice(0, limit); const Faces = styled.span` .face { display: inline-block; position:relative; height: 1.4em; width: 1.4em; min-width: 1.4em; vertical-align: top; img { object-fit: cover; border-radius: 50%; width: 100%; height: 100%; } } `; const Others = styled.span` &:hover { color: white !important; } `; const numLikes = likes.length - limit; return ( <> <Faces> {renderFaces.map((accountId, i) => ( <a key={i} href={`#/mob.near/widget/ProfilePage?accountId=${accountId}`} className="text-decoration-none d-inline-block" > <Widget src="mob.near/widget/Profile.OverlayTrigger" props={{ accountId, children: ( <Widget src="mob.near/widget/ProfileImage" props={{ metadata, accountId, widgetName, style: { zIndex: 10 - i }, className: "face", tooltip: false, imageStyle: {}, imageClassName: "", }} /> ), }} /> </a> ))} </Faces> {numLikes > 0 ? ( <OverlayTrigger placement="auto" overlay={ <Tooltip> <div className="text-truncate text-start" style={{ maxWidth: "16em" }} > {faces.slice(0, 10).map((accountId, i) => ( <Fragment key={i}> <Widget src="mob.near/widget/ProfileLine" props={{ accountId, link: false }} /> <br /> </Fragment> ))} {faces.length > 10 ? "..." : ""} </div> </Tooltip> } > <Others className="ms-1 text-muted"> and {numLikes} other{numLikes === 1 ? "" : "s"} </Others> </OverlayTrigger> ) : ( "" )} </> );