mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 06:36:14 +00:00
Adding correct comment ordering
This commit is contained in:
parent
2bb2b84737
commit
2b08fe5be9
|
@ -103,6 +103,7 @@ impl Comment {
|
||||||
pub fn from_post(conn: &PgConnection, post: &Post) -> Result<Vec<Self>, Error> {
|
pub fn from_post(conn: &PgConnection, post: &Post) -> Result<Vec<Self>, Error> {
|
||||||
use schema::community::dsl::*;
|
use schema::community::dsl::*;
|
||||||
Comment::belonging_to(post)
|
Comment::belonging_to(post)
|
||||||
|
.order_by(comment::published.desc())
|
||||||
.load::<Self>(conn)
|
.load::<Self>(conn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ export class Post extends Component<any, State> {
|
||||||
commentsTree() {
|
commentsTree() {
|
||||||
let nodes = this.buildCommentsTree();
|
let nodes = this.buildCommentsTree();
|
||||||
return (
|
return (
|
||||||
<div className="sticky-top">
|
<div className="">
|
||||||
<CommentNodes nodes={nodes} />
|
<CommentNodes nodes={nodes} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -147,7 +147,7 @@ export class Post extends Component<any, State> {
|
||||||
} else if (op == UserOperation.GetPost) {
|
} else if (op == UserOperation.GetPost) {
|
||||||
let res: PostResponse = msg;
|
let res: PostResponse = msg;
|
||||||
this.state.post = res.post;
|
this.state.post = res.post;
|
||||||
this.state.comments = res.comments.reverse();
|
this.state.comments = res.comments;
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
} else if (op == UserOperation.CreateComment) {
|
} else if (op == UserOperation.CreateComment) {
|
||||||
let res: CommentResponse = msg;
|
let res: CommentResponse = msg;
|
||||||
|
@ -177,10 +177,11 @@ export class CommentNodes extends Component<CommentNodesProps, CommentNodesState
|
||||||
return (
|
return (
|
||||||
<div className="comments">
|
<div className="comments">
|
||||||
{this.props.nodes.map(node =>
|
{this.props.nodes.map(node =>
|
||||||
<div className="comment ml-2">
|
<div className={`comment ${node.comment.parent_id ? 'ml-4' : ''}`}>
|
||||||
<div className="float-left small font-weight-light">
|
<div className="float-left small text-center">
|
||||||
<div className="pointer">▲</div>
|
<div className="pointer upvote">▲</div>
|
||||||
<div className="pointer">▼</div>
|
<div>20</div>
|
||||||
|
<div className="pointer downvote">▼</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="details ml-4">
|
<div className="details ml-4">
|
||||||
<ul class="list-inline mb-0 text-muted small">
|
<ul class="list-inline mb-0 text-muted small">
|
||||||
|
@ -189,7 +190,7 @@ export class CommentNodes extends Component<CommentNodesProps, CommentNodesState
|
||||||
</li>
|
</li>
|
||||||
<li className="list-inline-item">
|
<li className="list-inline-item">
|
||||||
<span>(
|
<span>(
|
||||||
<span className="text-info"> 1300</span>
|
<span className="text-info"> +1300</span>
|
||||||
<span> | </span>
|
<span> | </span>
|
||||||
<span className="text-danger">-29</span>
|
<span className="text-danger">-29</span>
|
||||||
<span> ) points</span>
|
<span> ) points</span>
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.pointer {
|
.pointer {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.upvote:hover {
|
||||||
|
color: var(--info);
|
||||||
|
}
|
||||||
|
|
||||||
|
.downvote:hover {
|
||||||
|
color: var(--danger);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue