diff options
Diffstat (limited to 'vnext/src/components/UserInfo.js')
-rw-r--r-- | vnext/src/components/UserInfo.js | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/vnext/src/components/UserInfo.js b/vnext/src/components/UserInfo.js index a65bd993..e92ccfd5 100644 --- a/vnext/src/components/UserInfo.js +++ b/vnext/src/components/UserInfo.js @@ -36,28 +36,23 @@ export default function UserInfo(props) { <div className="msg-ts">Was online recently</div> </Avatar> </div> + <UserSummary user={user} /> <div className="l"> { user.uid > 0 && <> <Link to="/pm"> - <Icon name="ei-envelope" size="s" />PM - </Link> + <Icon name="ei-envelope" size="s" /> + <span className="desktop">PM</span> + </Link> <Link to={`/${user.uname}/?show=recomm`} rel="nofollow"> - <Icon name="ei-heart" size="s" />Recommendations - </Link> + <Icon name="ei-heart" size="s" /> + <span className="desktop">Recommendations</span> + </Link> <Link to={`/${user.uname}/?media=1`} rel="nofollow"> - <Icon name="ei-camera" size="s" />Photos - </Link> - { - user.read && - <Link to={`/${user.uname}/friends`}>I read: {user.read.length}</Link> - } - <Link to={`/${user.uname}/readers`}>My readers: {user.readers ? user.readers.length : 0}</Link> - { - user.statsMyBL && - <Link to={`/${user.uname}/bl`}>My blacklist: {user.statsMyBL}</Link> - } + <Icon name="ei-camera" size="s" /> + <span className="desktop">Photos</span> + </Link> </> } </div> @@ -66,6 +61,24 @@ export default function UserInfo(props) { ); } +function Summary({ user }) { + let read = user.read && <Link to={`/${user.uname}/friends`}>I read: {user.read.length}</Link>; + let readers = user.readers && <Link to={`/${user.uname}/readers`}>My readers: {user.readers.length}</Link> + let mybl = user.statsMyBL && <Link to={`/${user.uname}/bl`}>My blacklist: {user.statsMyBL}</Link> + let presentItems = [read, readers, mybl].filter(Boolean); + return ( + <div className="msg-summary"> + {presentItems.length > 0 && presentItems.reduce((prev, curr) => [prev, ' ', curr])} + </div> + ); +} + +Summary.propTypes = { + user: UserType.isRequired +}; + +const UserSummary = React.memo(Summary); + export function UserLink(props) { const [user, setUser] = useState(props.user); useEffect(() => { @@ -84,8 +97,8 @@ export function UserLink(props) { }, [props.user]); return ( user.uid ? - <Link key={user.uid} to={`/${user.uname}/`} className="info-avatar"><img src={user.avatar}/>{user.uname}</Link> - : <a href={user.uri} className="info-avatar"><img src={user.avatar}/>{user.uname}</a> + <Link key={user.uid} to={`/${user.uname}/`} className="info-avatar"><img src={user.avatar} />{user.uname}</Link> + : <a href={user.uri} className="info-avatar"><img src={user.avatar} />{user.uname}</a> ); } |