From f66ff6fe82c575a5e71678234c9518a6a537927c Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 17 Dec 2018 12:24:52 +0300 Subject: Anonymous comments --- vnext/src/components/Avatar.js | 68 ++++++++++++++++++++++++++++-------------- vnext/src/components/Feeds.js | 10 +++---- vnext/src/components/Thread.js | 10 +++++-- vnext/src/components/Types.js | 2 +- 4 files changed, 59 insertions(+), 31 deletions(-) (limited to 'vnext/src/components') diff --git a/vnext/src/components/Avatar.js b/vnext/src/components/Avatar.js index 6ea0d5d5..a83107ce 100644 --- a/vnext/src/components/Avatar.js +++ b/vnext/src/components/Avatar.js @@ -6,33 +6,54 @@ import { UserType } from './Types'; import Icon from './Icon'; +import { fetchUserUri } from '../api'; + import './Avatar.css'; -const Avatar = React.memo(props => { - return ( -
-
- { - props.user.uname ? - - { props.user.avatar ? - {`${props.user.uname}`} - : } +class Avatar extends React.Component { + constructor(props) { + super(props); + this.state = { + user: props.user + }; + } + componentDidMount() { + let user = this.state.user; + if (!user.uid && user.uri) { + fetchUserUri(user.uri).then(response => { + this.setState({ + user: response.data + }); + }); + } + } + render() { + let user = this.state.user; + return ( +
+
+ { + user.uname ? + + {user.avatar ? + {`${user.uname}`} + : } + + : + } +
+
+ + + {user.uname} - : - } -
-
- - - {props.user.uname} - - - {props.children} + + {this.props.children} +
-
- ); -}); + ); + } +} export default Avatar; @@ -48,5 +69,6 @@ export const AvatarLink = React.memo(props => { Avatar.propTypes = { user: UserType, link: PropTypes.string, + style: PropTypes.object, children: PropTypes.node }; diff --git a/vnext/src/components/Feeds.js b/vnext/src/components/Feeds.js index e8558084..430ce9f1 100644 --- a/vnext/src/components/Feeds.js +++ b/vnext/src/components/Feeds.js @@ -16,7 +16,7 @@ import { UserType } from './Types'; export function Discover(props) { let search = qs.parse(props.location.search.substring(1)); const query = { - baseUrl: '/messages', + baseUrl: '/api/messages', search: search, pageParam: search.search ? 'page' : 'before_mid' }; @@ -25,7 +25,7 @@ export function Discover(props) { export function Discussions(props) { const query = { - baseUrl: '/messages/discussions', + baseUrl: '/api/messages/discussions', pageParam: 'to' }; return (); @@ -36,7 +36,7 @@ export function Blog(props) { let search = qs.parse(props.location.search.substring(1)); search.uname = user; const query = { - baseUrl: '/messages', + baseUrl: '/api/messages', search: search, pageParam: search.search ? 'page' : 'before_mid' }; @@ -53,7 +53,7 @@ export function Blog(props) { export function Tag(props) { const { tag } = props.match.params; const query = { - baseUrl: '/messages', + baseUrl: '/api/messages', search: { tag: tag }, @@ -64,7 +64,7 @@ export function Tag(props) { export function Home(props) { const query = { - baseUrl: '/home', + baseUrl: '/api/home', pageParam: 'before_mid' }; return (); diff --git a/vnext/src/components/Thread.js b/vnext/src/components/Thread.js index b824c0ed..cf7291a8 100644 --- a/vnext/src/components/Thread.js +++ b/vnext/src/components/Thread.js @@ -41,7 +41,7 @@ export default class Thread extends React.Component { if (this.props.visitor && this.props.visitor.hash) { params.hash = this.props.visitor.hash; } - getMessages('/thread', params) + getMessages('/api/thread', params) .then(response => { let msg = response.data.shift(); this.setState({ @@ -111,7 +111,13 @@ export default class Thread extends React.Component {
-

= 0) }}>

+ { + msg.html ?
+ : +
+

= 0) }} /> +

+ } { msg.photo &&

diff --git a/vnext/src/components/Types.js b/vnext/src/components/Types.js index 6596dc8e..db90d41e 100644 --- a/vnext/src/components/Types.js +++ b/vnext/src/components/Types.js @@ -1,7 +1,7 @@ import PropTypes from 'prop-types'; export const UserType = PropTypes.shape({ - uid: PropTypes.number.isRequired, + uid: PropTypes.number, uname: PropTypes.string }); -- cgit v1.2.3