mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-01 16:51:21 +00:00
Post and comment vote views now return 0 instead of null.
- Fixes #1389
This commit is contained in:
parent
9609bd99bb
commit
d2ba2960dd
2 changed files with 18 additions and 2 deletions
|
@ -81,7 +81,7 @@ impl CommentView {
|
||||||
creator_banned_from_community,
|
creator_banned_from_community,
|
||||||
subscribed,
|
subscribed,
|
||||||
saved,
|
saved,
|
||||||
my_vote,
|
comment_like,
|
||||||
) = comment::table
|
) = comment::table
|
||||||
.find(comment_id)
|
.find(comment_id)
|
||||||
.inner_join(user_::table)
|
.inner_join(user_::table)
|
||||||
|
@ -134,6 +134,14 @@ impl CommentView {
|
||||||
))
|
))
|
||||||
.first::<CommentViewTuple>(conn)?;
|
.first::<CommentViewTuple>(conn)?;
|
||||||
|
|
||||||
|
// If a user is given, then my_vote, if None, should be 0, not null
|
||||||
|
// Necessary to differentiate between other user's votes
|
||||||
|
let my_vote = if my_user_id.is_some() && comment_like.is_none() {
|
||||||
|
Some(0)
|
||||||
|
} else {
|
||||||
|
comment_like
|
||||||
|
};
|
||||||
|
|
||||||
Ok(CommentView {
|
Ok(CommentView {
|
||||||
comment,
|
comment,
|
||||||
recipient,
|
recipient,
|
||||||
|
|
|
@ -70,7 +70,7 @@ impl PostView {
|
||||||
follower,
|
follower,
|
||||||
saved,
|
saved,
|
||||||
read,
|
read,
|
||||||
my_vote,
|
post_like,
|
||||||
) = post::table
|
) = post::table
|
||||||
.find(post_id)
|
.find(post_id)
|
||||||
.inner_join(user_::table)
|
.inner_join(user_::table)
|
||||||
|
@ -124,6 +124,14 @@ impl PostView {
|
||||||
))
|
))
|
||||||
.first::<PostViewTuple>(conn)?;
|
.first::<PostViewTuple>(conn)?;
|
||||||
|
|
||||||
|
// If a user is given, then my_vote, if None, should be 0, not null
|
||||||
|
// Necessary to differentiate between other user's votes
|
||||||
|
let my_vote = if my_user_id.is_some() && post_like.is_none() {
|
||||||
|
Some(0)
|
||||||
|
} else {
|
||||||
|
post_like
|
||||||
|
};
|
||||||
|
|
||||||
Ok(PostView {
|
Ok(PostView {
|
||||||
post,
|
post,
|
||||||
creator,
|
creator,
|
||||||
|
|
Loading…
Reference in a new issue