diff --git a/src/shared/components/comment/comment-node.tsx b/src/shared/components/comment/comment-node.tsx index d38a7af9..2fabba11 100644 --- a/src/shared/components/comment/comment-node.tsx +++ b/src/shared/components/comment/comment-node.tsx @@ -52,6 +52,7 @@ import { CommentNodeI, CommentViewType, PurgeType, + VoteContentType, } from "../../interfaces"; import { mdToHtml, mdToHtmlNoImages } from "../../markdown"; import { I18NextService, UserService } from "../../services"; @@ -437,6 +438,7 @@ export class CommentNode extends Component { {UserService.Instance.myUserInfo && !this.props.viewOnly && ( <> void; enableDownvotes?: boolean; @@ -46,21 +47,45 @@ const tippy = (counts: CommentAggregates | PostAggregates): string => { const handleUpvote = (i: VoteButtons) => { i.setState({ upvoteLoading: true }); - i.props.onVote({ - id: i.props.id, - score: newVote(VoteType.Upvote, i.props.my_vote), - auth: myAuthRequired(), - }); + + switch (i.props.voteContentType) { + case VoteContentType.Comment: + i.props.onVote({ + comment_id: i.props.id, + score: newVote(VoteType.Upvote, i.props.my_vote), + auth: myAuthRequired(), + }); + break; + case VoteContentType.Post: + default: + i.props.onVote({ + post_id: i.props.id, + score: newVote(VoteType.Upvote, i.props.my_vote), + auth: myAuthRequired(), + }); + } + i.setState({ upvoteLoading: false }); }; const handleDownvote = (i: VoteButtons) => { i.setState({ downvoteLoading: true }); - i.props.onVote({ - id: i.props.id, - score: newVote(VoteType.Downvote, i.props.my_vote), - auth: myAuthRequired(), - }); + switch (i.props.voteContentType) { + case VoteContentType.Comment: + i.props.onVote({ + comment_id: i.props.id, + score: newVote(VoteType.Downvote, i.props.my_vote), + auth: myAuthRequired(), + }); + break; + case VoteContentType.Post: + default: + i.props.onVote({ + post_id: i.props.id, + score: newVote(VoteType.Downvote, i.props.my_vote), + auth: myAuthRequired(), + }); + } i.setState({ downvoteLoading: false }); }; diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index e8ab95eb..5a5ffe09 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -43,7 +43,12 @@ import { TransferCommunity, } from "lemmy-js-client"; import { relTags } from "../../config"; -import { BanType, PostFormParams, PurgeType } from "../../interfaces"; +import { + BanType, + PostFormParams, + PurgeType, + VoteContentType, +} from "../../interfaces"; import { mdNoImages, mdToHtml, mdToHtmlInline } from "../../markdown"; import { I18NextService, UserService } from "../../services"; import { setupTippy } from "../../tippy"; @@ -598,6 +603,7 @@ export class PostListing extends Component { )} {mobile && !this.props.viewOnly && ( {
{!this.props.viewOnly && ( ;