From e7b32a80cdcf0fa9ca97c14cda33db6d81b451d6 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Wed, 12 Dec 2018 15:47:28 +0300
Subject: read/readers
---
vnext/src/components/Avatar.js | 6 +++--
vnext/src/components/UserInfo.js | 15 ++++-------
vnext/src/components/Users.js | 58 +++++++++++++++++++++++++---------------
3 files changed, 46 insertions(+), 33 deletions(-)
(limited to 'vnext/src/components')
diff --git a/vnext/src/components/Avatar.js b/vnext/src/components/Avatar.js
index 002badde..e2023649 100644
--- a/vnext/src/components/Avatar.js
+++ b/vnext/src/components/Avatar.js
@@ -8,12 +8,14 @@ import Icon from './Icon';
const Avatar = React.memo(props => {
return (
-
+
{
props.user.uname ?
-
+ { props.user.avatar ?
+
+ :
}
:
}
diff --git a/vnext/src/components/UserInfo.js b/vnext/src/components/UserInfo.js
index c4247f92..5e60f95f 100644
--- a/vnext/src/components/UserInfo.js
+++ b/vnext/src/components/UserInfo.js
@@ -22,8 +22,9 @@ export default class UserInfo extends React.Component {
componentDidMount() {
info(this.state.user.uname).then(response => {
this.setState({
- user: response.data[0]
+ user: response.data
});
+ this.props.onUpdate && this.props.onUpdate(response.data);
});
}
render() {
@@ -70,23 +71,17 @@ export default class UserInfo extends React.Component {
Messages: {user.statsMessages}
Comments: {user.statsReplies}
- {
- user.read &&
-
- {
- user.read.map(u =>
)
- }
-
- }
>
}
+ { this.props.children }
>
);
}
}
UserInfo.propTypes = {
- user: PropTypes.string.isRequired
+ user: PropTypes.string.isRequired,
+ onUpdate: PropTypes.func
};
diff --git a/vnext/src/components/Users.js b/vnext/src/components/Users.js
index c0da3748..2bab6de1 100644
--- a/vnext/src/components/Users.js
+++ b/vnext/src/components/Users.js
@@ -1,41 +1,57 @@
import React from 'react';
import PropTypes from 'prop-types';
-import { Link } from 'react-router-dom';
+
import { UserType } from './Types';
+import UserInfo from './UserInfo';
+import Avatar from './Avatar';
-export function Friends({ visitor, ...rest }) {
- return
;
+export function Friends({ user, ...rest }) {
+ return
;
}
-export function Readers({ visitor, ...rest }) {
- return
;
+export function Readers({ user, ...rest }) {
+ return
;
}
-function Users({data, ...rest}) {
- return (
-
- {
- data.map(user =>
-
-
- {user.uname}
-
- )
- }
-
- );
+class Users extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ user: {}
+ };
+ }
+ updateUser = (user) => {
+ this.setState({
+ user: user
+ });
+ }
+ render() {
+ return (
+
+
+ {
+ this.state.user[this.props.prop] &&
+ this.state.user[this.props.prop].map(user =>
+
+ )
+ }
+
+
+ );
+ }
}
Friends.propTypes = {
- visitor: UserType
+ user: PropTypes.string.isRequired
};
Readers.propTypes = {
- visitor: UserType
+ user: PropTypes.string.isRequired
};
Users.propTypes = {
- data: PropTypes.arrayOf(UserType).isRequired
+ user: PropTypes.string.isRequired,
+ prop: PropTypes.string.isRequired
};
--
cgit v1.2.3