From bda9e6f9c69378306dbfa6e3ebfa633684b87b1a Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 28 Nov 2023 20:31:01 -0500 Subject: [PATCH] Disable post voting buttons when logged out. Fixes #2248 --- src/shared/components/common/vote-buttons.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/shared/components/common/vote-buttons.tsx b/src/shared/components/common/vote-buttons.tsx index 91e8156c..d67d2bce 100644 --- a/src/shared/components/common/vote-buttons.tsx +++ b/src/shared/components/common/vote-buttons.tsx @@ -9,7 +9,7 @@ import { PostAggregates, } from "lemmy-js-client"; import { VoteContentType, VoteType } from "../../interfaces"; -import { I18NextService } from "../../services"; +import { I18NextService, UserService } from "../../services"; import { Icon, Spinner } from "../common/icon"; interface VoteButtonsProps { @@ -113,6 +113,7 @@ export class VoteButtonsCompact extends Component< this.props.my_vote === 1 ? "text-info" : "text-muted" }`} data-tippy-content={tippy(this.props.counts)} + disabled={!UserService.Instance.myUserInfo} onClick={linkEvent(this, handleUpvote)} aria-label={I18NextService.i18n.t("upvote")} aria-pressed={this.props.my_vote === 1} @@ -136,6 +137,7 @@ export class VoteButtonsCompact extends Component< className={`ms-2 btn btn-sm btn-link btn-animate btn py-0 px-1 ${ this.props.my_vote === -1 ? "text-danger" : "text-muted" }`} + disabled={!UserService.Instance.myUserInfo} onClick={linkEvent(this, handleDownvote)} data-tippy-content={tippy(this.props.counts)} aria-label={I18NextService.i18n.t("downvote")} @@ -191,6 +193,7 @@ export class VoteButtons extends Component { className={`btn-animate btn btn-link p-0 ${ this.props.my_vote === 1 ? "text-info" : "text-muted" }`} + disabled={!UserService.Instance.myUserInfo} onClick={linkEvent(this, handleUpvote)} data-tippy-content={I18NextService.i18n.t("upvote")} aria-label={I18NextService.i18n.t("upvote")} @@ -218,6 +221,7 @@ export class VoteButtons extends Component { className={`btn-animate btn btn-link p-0 ${ this.props.my_vote === -1 ? "text-danger" : "text-muted" }`} + disabled={!UserService.Instance.myUserInfo} onClick={linkEvent(this, handleDownvote)} data-tippy-content={I18NextService.i18n.t("downvote")} aria-label={I18NextService.i18n.t("downvote")}