From f470636a70943a8ecad8bddc791a1c2dddd28e1e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 4 May 2019 21:13:12 +0300 Subject: Components -> UI --- vnext/src/components/UserInfo.js | 117 --------------------------------------- 1 file changed, 117 deletions(-) delete mode 100644 vnext/src/components/UserInfo.js (limited to 'vnext/src/components/UserInfo.js') diff --git a/vnext/src/components/UserInfo.js b/vnext/src/components/UserInfo.js deleted file mode 100644 index 7d84488e..00000000 --- a/vnext/src/components/UserInfo.js +++ /dev/null @@ -1,117 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import PropTypes from 'prop-types'; -import { Link } from 'react-router-dom'; - -import { UserType } from './Types'; - -import { info, fetchUserUri } from '../api'; - -import Avatar from './Avatar'; -import Icon from './Icon'; -import SearchBox from './SearchBox'; - -import './UserInfo.css'; - -let isMounted; - -export default function UserInfo(props) { - const [user, setUser] = useState({ uname: props.user, uid: 0 }); - const { onUpdate } = props; - useEffect(() => { - isMounted = true; - if (!user.avatar) { - info(user.uname).then(response => { - if (isMounted) { - setUser(response.data); - onUpdate && onUpdate(response.data); - } - }); - } - return () => { - isMounted = false; - }; - }, [onUpdate, user, user.avatar]); - return ( - <> -
- -
Was online recently
-
-
- -
- { - user.uid > 0 && - <> - - - PM - - - - Recommendations - - - - Photos - - - } -
- {props.children} - - ); -} - -function Summary({ user }) { - const readUrl = `/${user.uname}/friends`; - const readersUrl = `/${user.uname}/readers`; - const blUrl = `/${user.uname}/bl`; - let read = user.read && I read: {user.read.length}; - let readers = user.readers && My readers: {user.readers.length}; - let mybl = user.statsMyBL && My blacklist: {user.statsMyBL}; - let presentItems = [read, readers, mybl].filter(Boolean); - return ( -
- {presentItems.length > 0 && presentItems.reduce((prev, curr) => [prev, ' ', curr])} -
- ); -} - -Summary.propTypes = { - user: UserType.isRequired -}; - -const UserSummary = React.memo(Summary); - -export function UserLink(props) { - const [user, setUser] = useState(props.user); - useEffect(() => { - isMounted = true; - if (!user.uid && user.uri) { - fetchUserUri(user.uri).then(response => { - if (isMounted) { - setUser({ ...response.data, uid: 66666666 }); - } - }); - } - return () => { - isMounted = false; - }; - }, [user.uid, user.uri]); - return ( - user.uid ? - {user.uname} - : {user.uname} - ); -} - -UserInfo.propTypes = { - user: PropTypes.string.isRequired, - onUpdate: PropTypes.func, - children: PropTypes.node -}; - -UserLink.propTypes = { - user: UserType.isRequired -}; -- cgit v1.2.3