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