{this.state.posts.length > 0
? this.state.posts.map(post =>
<PostListing post={post} showCommunity={!this.props.communityId}/>)
- : <div>No Listings</div>
+ : <div>No Listings. Subscribe to some <Link to="/communities">forums</Link>.</div>
}
</div>
)
commentSort: CommentSortType;
community: Community;
moderators: Array<CommunityUser>;
+ scrolled: boolean;
}
export class Post extends Component<any, PostState> {
comments: [],
commentSort: CommentSortType.Hot,
community: null,
- moderators: []
+ moderators: [],
+ scrolled: false
}
constructor(props, context) {
autosize(document.querySelectorAll('textarea'));
}
+ componentDidUpdate(lastProps: any, lastState: PostState, snapshot: any) {
+ if (!this.state.scrolled && lastState.comments.length > 0 && window.location.href.includes('#comment-')) {
+ let id = window.location.hash.split("#")[2];
+ var elmnt = document.getElementById(`${id}`);
+ elmnt.scrollIntoView();
+ this.state.scrolled = true;
+ }
+ }
+
render() {
return (
<div class="container">
render() {
let node = this.props.node;
return (
- <div className={`comment ${node.comment.parent_id && !this.props.noIndent ? 'ml-4' : ''}`}>
+ <div id={`comment-${node.comment.id}`} className={`comment ${node.comment.parent_id && !this.props.noIndent ? 'ml-4' : ''}`}>
<div className="float-left small text-center">
<div className={`pointer upvote ${node.comment.my_vote == 1 ? 'text-info' : 'text-muted'}`} onClick={linkEvent(node, this.handleCommentLike)}>▲</div>
<div>{node.comment.score}</div>
</li>
}
<li className="list-inline-item">
- <a className="text-muted" href="test">link</a>
+ <Link className="text-muted" to={`/post/${node.comment.post_id}#comment-${node.comment.id}`}>link</Link>
</li>
</ul>
</div>