|
|
@ -3,6 +3,7 @@ import { Link, withRouter } from 'react-router'; |
|
|
|
import { drizzleConnect } from 'drizzle-react'; |
|
|
|
import PropTypes from 'prop-types'; |
|
|
|
|
|
|
|
import { Transition } from 'semantic-ui-react' |
|
|
|
import { Grid, Divider, Button, Icon, Label } from 'semantic-ui-react' |
|
|
|
|
|
|
|
import TimeAgo from 'react-timeago'; |
|
|
@ -15,12 +16,18 @@ class Post extends Component { |
|
|
|
super(props); |
|
|
|
|
|
|
|
this.fetchPost = this.fetchPost.bind(this); |
|
|
|
if (props.getFocus){ |
|
|
|
this.postRef = React.createRef(); |
|
|
|
} |
|
|
|
|
|
|
|
this.orbitPostData = { |
|
|
|
content: "", |
|
|
|
subject: "" |
|
|
|
}; |
|
|
|
this.orbitPostDataFetchStatus = "pending"; |
|
|
|
this.state = { |
|
|
|
animateOnToggle: true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async fetchPost(postID) { |
|
|
@ -44,6 +51,7 @@ class Post extends Component { |
|
|
|
} |
|
|
|
} |
|
|
|
this.orbitPostDataFetchStatus = "fetched"; |
|
|
|
this.readyForAnimation = true; |
|
|
|
} |
|
|
|
|
|
|
|
render(){ |
|
|
@ -57,74 +65,76 @@ class Post extends Component { |
|
|
|
); |
|
|
|
|
|
|
|
return ( |
|
|
|
<div className="post"> |
|
|
|
<Divider horizontal> |
|
|
|
<span className="grey-text">#{this.props.postIndex}</span> |
|
|
|
</Divider> |
|
|
|
<Grid> |
|
|
|
<Grid.Row columns={16} stretched> |
|
|
|
<Grid.Column width={1} className="user-avatar"> |
|
|
|
{this.props.blockchainData[0].returnData !== null |
|
|
|
?<Link to={"/profile/" + this.props.blockchainData[0].returnData[1] |
|
|
|
+ "/" + this.props.blockchainData[0].returnData[2]} |
|
|
|
onClick={(event) => {event.stopPropagation()}}> |
|
|
|
{avatarView} |
|
|
|
</Link> |
|
|
|
:avatarView |
|
|
|
} |
|
|
|
</Grid.Column> |
|
|
|
<Grid.Column width={15}> |
|
|
|
<div className=""> |
|
|
|
<div className="stretch-space-between"> |
|
|
|
<span className={this.props.blockchainData[0].returnData !== null ? "" : "grey-text"}> |
|
|
|
<strong> |
|
|
|
{this.props.blockchainData[0].returnData !== null |
|
|
|
?this.props.blockchainData[0].returnData[2] |
|
|
|
:"Username" |
|
|
|
<Transition animation='tada' duration={500} visible={this.state.animateOnToggle}> |
|
|
|
<div className="post" ref={this.postRef ? this.postRef : null}> |
|
|
|
<Divider horizontal> |
|
|
|
<span className="grey-text">#{this.props.postIndex}</span> |
|
|
|
</Divider> |
|
|
|
<Grid> |
|
|
|
<Grid.Row columns={16} stretched> |
|
|
|
<Grid.Column width={1} className="user-avatar"> |
|
|
|
{this.props.blockchainData[0].returnData !== null |
|
|
|
?<Link to={"/profile/" + this.props.blockchainData[0].returnData[1] |
|
|
|
+ "/" + this.props.blockchainData[0].returnData[2]} |
|
|
|
onClick={(event) => {event.stopPropagation()}}> |
|
|
|
{avatarView} |
|
|
|
</Link> |
|
|
|
:avatarView |
|
|
|
} |
|
|
|
</Grid.Column> |
|
|
|
<Grid.Column width={15}> |
|
|
|
<div className=""> |
|
|
|
<div className="stretch-space-between"> |
|
|
|
<span className={this.props.blockchainData[0].returnData !== null ? "" : "grey-text"}> |
|
|
|
<strong> |
|
|
|
{this.props.blockchainData[0].returnData !== null |
|
|
|
?this.props.blockchainData[0].returnData[2] |
|
|
|
:"Username" |
|
|
|
} |
|
|
|
</strong> |
|
|
|
</span> |
|
|
|
<span className="grey-text"> |
|
|
|
{this.props.blockchainData[0].returnData !== null && |
|
|
|
<TimeAgo date={epochTimeConverter(this.props.blockchainData[0].returnData[3])}/> |
|
|
|
} |
|
|
|
</strong> |
|
|
|
</span> |
|
|
|
<span className="grey-text"> |
|
|
|
{this.props.blockchainData[0].returnData !== null && |
|
|
|
<TimeAgo date={epochTimeConverter(this.props.blockchainData[0].returnData[3])}/> |
|
|
|
</span> |
|
|
|
</div> |
|
|
|
<div className="stretch-space-between"> |
|
|
|
<span className={this.orbitPostData.subject ? "" : "grey-text"}> |
|
|
|
<strong> |
|
|
|
Subject: {this.orbitPostData.subject} |
|
|
|
</strong> |
|
|
|
</span> |
|
|
|
</div> |
|
|
|
<div className="post-content"> |
|
|
|
{this.orbitPostData.content |
|
|
|
? <ReactMarkdown source={this.orbitPostData.content} /> |
|
|
|
: <p className="grey-text">Post content...</p> |
|
|
|
} |
|
|
|
</span> |
|
|
|
</div> |
|
|
|
<div className="stretch-space-between"> |
|
|
|
<span className={this.orbitPostData.subject ? "" : "grey-text"}> |
|
|
|
<strong> |
|
|
|
Subject: {this.orbitPostData.subject} |
|
|
|
</strong> |
|
|
|
</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="post-content"> |
|
|
|
{this.orbitPostData.content |
|
|
|
? <ReactMarkdown source={this.orbitPostData.content} /> |
|
|
|
: <p className="grey-text">Post content...</p> |
|
|
|
} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</Grid.Column> |
|
|
|
</Grid.Row> |
|
|
|
<Grid.Row> |
|
|
|
<Grid.Column floated="right" textAlign="right"> |
|
|
|
<Button icon size='mini' style={{marginRight: "0px"}}> |
|
|
|
<Icon name='chevron up' /> |
|
|
|
</Button> |
|
|
|
<Label color="teal">8000</Label> |
|
|
|
<Button icon size='mini'> |
|
|
|
<Icon name='chevron down' /> |
|
|
|
</Button> |
|
|
|
<Button icon size='mini' |
|
|
|
onClick={() => { this.context.router.push("/topic/" |
|
|
|
+ this.props.blockchainData[0].returnData[4] + "/" |
|
|
|
+ this.props.postID)}}> |
|
|
|
<Icon name='linkify' /> |
|
|
|
</Button> |
|
|
|
</Grid.Column> |
|
|
|
</Grid.Row> |
|
|
|
</Grid> |
|
|
|
</div> |
|
|
|
</Grid.Column> |
|
|
|
</Grid.Row> |
|
|
|
<Grid.Row> |
|
|
|
<Grid.Column floated="right" textAlign="right"> |
|
|
|
<Button icon size='mini' style={{marginRight: "0px"}}> |
|
|
|
<Icon name='chevron up' /> |
|
|
|
</Button> |
|
|
|
<Label color="teal">8000</Label> |
|
|
|
<Button icon size='mini'> |
|
|
|
<Icon name='chevron down' /> |
|
|
|
</Button> |
|
|
|
<Button icon size='mini' |
|
|
|
onClick={() => { this.context.router.push("/topic/" |
|
|
|
+ this.props.blockchainData[0].returnData[4] + "/" |
|
|
|
+ this.props.postID)}}> |
|
|
|
<Icon name='linkify' /> |
|
|
|
</Button> |
|
|
|
</Grid.Column> |
|
|
|
</Grid.Row> |
|
|
|
</Grid> |
|
|
|
</div> |
|
|
|
</Transition> |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@ -133,6 +143,17 @@ class Post extends Component { |
|
|
|
&& this.orbitPostDataFetchStatus === "pending") { |
|
|
|
this.fetchPost(this.props.postID); |
|
|
|
} |
|
|
|
if (this.readyForAnimation){ |
|
|
|
if (this.postRef){ |
|
|
|
setTimeout(() => { |
|
|
|
this.postRef.current.scrollIntoView({ block: 'start', behavior: 'smooth' }); |
|
|
|
setTimeout(() => { |
|
|
|
this.setState({ animateOnToggle: false }); |
|
|
|
}, 300); |
|
|
|
}, 100); |
|
|
|
this.readyForAnimation = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|