CommentNodeI,
CommentViewType,
PurgeType,
+ VoteContentType,
} from "../../interfaces";
import { mdToHtml, mdToHtmlNoImages } from "../../markdown";
import { I18NextService, UserService } from "../../services";
{UserService.Instance.myUserInfo && !this.props.viewOnly && (
<>
<VoteButtonsCompact
+ voteContentType={VoteContentType.Comment}
id={this.commentView.comment.id}
onVote={this.props.onCommentVote}
enableDownvotes={this.props.enableDownvotes}
CreatePostLike,
PostAggregates,
} from "lemmy-js-client";
-import { VoteType } from "../../interfaces";
+import { VoteContentType, VoteType } from "../../interfaces";
import { I18NextService } from "../../services";
import { Icon, Spinner } from "../common/icon";
interface VoteButtonsProps {
+ voteContentType: VoteContentType;
id: number;
onVote: (i: CreateCommentLike | CreatePostLike) => void;
enableDownvotes?: boolean;
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 });
};
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";
)}
{mobile && !this.props.viewOnly && (
<VoteButtonsCompact
+ voteContentType={VoteContentType.Post}
id={this.postView.post.id}
onVote={this.props.onPostVote}
enableDownvotes={this.props.enableDownvotes}
<article className="row post-container">
{!this.props.viewOnly && (
<VoteButtons
+ voteContentType={VoteContentType.Post}
id={this.postView.post.id}
onVote={this.props.onPostVote}
enableDownvotes={this.props.enableDownvotes}