From 6f1fb6b3bf531e3d2d450458a59aae7096bf0b63 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 9 Apr 2021 12:23:30 -0400 Subject: [PATCH] Showing / hiding scores based on setting. Fixes #241 --- lemmy-translations | 2 +- package.json | 2 +- src/shared/components/comment-node.tsx | 49 ++++++++------- src/shared/components/person.tsx | 35 ++++++++--- src/shared/components/post-listing.tsx | 82 +++++++++++++++++--------- src/shared/utils.ts | 7 +++ yarn.lock | 8 +-- 7 files changed, 122 insertions(+), 63 deletions(-) diff --git a/lemmy-translations b/lemmy-translations index f055624..f36cf23 160000 --- a/lemmy-translations +++ b/lemmy-translations @@ -1 +1 @@ -Subproject commit f05562455f5260d266d72b6130abb6f633e88a02 +Subproject commit f36cf2332878286378303d0ce9629728b3889ac9 diff --git a/package.json b/package.json index 293d531..b9377cf 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "eslint-plugin-prettier": "^3.3.1", "husky": "^6.0.0", "iso-639-1": "^2.1.9", - "lemmy-js-client": "0.11.0-rc.4", + "lemmy-js-client": "0.11.0-rc.6", "lint-staged": "^10.5.4", "mini-css-extract-plugin": "^1.4.1", "node-fetch": "^2.6.1", diff --git a/src/shared/components/comment-node.tsx b/src/shared/components/comment-node.tsx index a5a2733..0e7db68 100644 --- a/src/shared/components/comment-node.tsx +++ b/src/shared/components/comment-node.tsx @@ -29,6 +29,7 @@ import { colorList, wsClient, authField, + showScores, } from "../utils"; import moment from "moment"; import { MomentTime } from "./moment-time"; @@ -200,21 +201,25 @@ export class CommentNode extends Component { {/* This is an expanding spacer for mobile */}
- - - {this.state.score} - - - • + {showScores() && ( + <> + + + {this.state.score} + + + • + + )} @@ -281,9 +286,10 @@ export class CommentNode extends Component { aria-label={i18n.t("upvote")} > - {this.state.upvotes !== this.state.score && ( - {this.state.upvotes} - )} + {showScores() && + this.state.upvotes !== this.state.score && ( + {this.state.upvotes} + )} {this.props.enableDownvotes && ( )} -
- {this.state.score} -
+ {showScores() ? ( +
+ {this.state.score} +
+ ) : ( +
+ )} {this.props.enableDownvotes && ( {!mobile && ( <> - {this.state.downvotes !== 0 && ( + {this.state.downvotes !== 0 && showScores() && ( - {this.props.enableDownvotes && ( + {showScores() ? ( + ) : ( + )} + {this.props.enableDownvotes && + (showScores() ? ( + + ) : ( + + ))}